bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
1 |
# Copyright (C) 2006 by Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License version 2 as published by
|
|
5 |
# the Free Software Foundation.
|
|
6 |
#
|
|
7 |
# This program is distributed in the hope that it will be useful,
|
|
8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
# GNU General Public License for more details.
|
|
11 |
#
|
|
12 |
# You should have received a copy of the GNU General Public License
|
|
13 |
# along with this program; if not, write to the Free Software
|
|
14 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15 |
||
16 |
"""Tests for bzr bundle performance."""
|
|
17 |
||
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
18 |
import os |
|
1908.8.3
by Carl Friedrich Bolz
(cfbolz, hpk): Add caching mechanism and add benchmark for bundle-reading. |
19 |
import shutil |
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
20 |
from cStringIO import StringIO |
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
21 |
|
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
22 |
from bzrlib.benchmarks import Benchmark |
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
23 |
from bzrlib.branch import Branch |
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
24 |
from bzrlib.bundle import read_bundle |
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
25 |
from bzrlib.bundle.serializer import write_bundle |
26 |
from bzrlib.revisionspec import RevisionSpec |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
27 |
from bzrlib.workingtree import WorkingTree |
28 |
||
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
29 |
|
30 |
class BundleBenchmark(Benchmark): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
31 |
"""The bundle tests should (also) be done at a lower level with |
32 |
direct call to the bzrlib.
|
|
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
33 |
"""
|
|
1908.8.5
by holger krekel
route more creation code through cached_make |
34 |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
35 |
def make_kernel_like_tree_committed(self): |
36 |
self.make_kernel_like_tree_added() |
|
|
1908.8.5
by holger krekel
route more creation code through cached_make |
37 |
self.run_bzr('commit', '-m', 'initial import') |
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
38 |
|
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
39 |
def test_create_bundle_known_kernel_like_tree(self): |
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
40 |
"""Create a bundle for a kernel sized tree with no ignored, unknowns, |
41 |
or added and one commit.
|
|
42 |
"""
|
|
43 |
self.make_kernel_like_tree_committed() |
|
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
44 |
self.time(self.run_bzr, 'bundle', '--revision', '..-1') |
45 |
||
46 |
def test_create_bundle_many_commit_tree (self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
47 |
"""Create a bundle for a tree with many commits but no changes.""" |
48 |
self.make_many_commit_tree() |
|
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
49 |
self.time(self.run_bzr, 'bundle', '--revision', '..-1') |
50 |
||
51 |
def test_create_bundle_heavily_merged_tree(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
52 |
"""Create a bundle for a heavily merged tree.""" |
53 |
self.make_heavily_merged_tree() |
|
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
54 |
self.time(self.run_bzr, 'bundle', '--revision', '..-1') |
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
55 |
|
|
1908.3.3
by Carl Friedrich Bolz
Add benchmark for applying a benchmark and fix some formatting/typos. |
56 |
def test_apply_bundle_known_kernel_like_tree(self): |
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
57 |
"""Create a bundle for a kernel sized tree with no ignored, unknowns, |
58 |
or added and one commit.
|
|
59 |
"""
|
|
60 |
self.make_kernel_like_tree_committed() |
|
|
1908.3.3
by Carl Friedrich Bolz
Add benchmark for applying a benchmark and fix some formatting/typos. |
61 |
f = file('../bundle', 'wb') |
62 |
try: |
|
63 |
f.write(self.run_bzr('bundle', '--revision', '..-1')[0]) |
|
64 |
finally: |
|
65 |
f.close() |
|
|
1908.8.5
by holger krekel
route more creation code through cached_make |
66 |
self.run_bzr("init", "../branch_a") |
|
1908.3.3
by Carl Friedrich Bolz
Add benchmark for applying a benchmark and fix some formatting/typos. |
67 |
os.chdir('../branch_a') |
68 |
self.time(self.run_bzr, 'merge', '../bundle') |
|
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
69 |
|
|
1868.1.5
by Jan Balster
benchmarks for "bzr bundle --revision ..-1" |
70 |
|
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
71 |
class BundleLibraryLevelBenchmark(Benchmark): |
72 |
||
73 |
def make_parametrized_tree(self, num_files, num_revisions, |
|
74 |
num_files_in_bundle): |
|
75 |
"""Create a tree with given parameters. Always creates 2 levels of |
|
76 |
directories with the given number of files. Then the given number of
|
|
77 |
revisions are created, changing some lines in one files in each
|
|
78 |
revision. Only num_files_in_bundle files are changed in these
|
|
79 |
revisions.
|
|
80 |
||
81 |
:param num_files: number of files in tree
|
|
82 |
:param num_revisions: number of revisions
|
|
83 |
:param num_files_in_bundle: number of files changed in the revisions
|
|
84 |
"""
|
|
85 |
directories = [] |
|
86 |
files = [] |
|
87 |
count = 0 |
|
88 |
for outer in range(num_files // 64 + 1): |
|
89 |
directories.append("%s/" % outer) |
|
90 |
for middle in range(8): |
|
91 |
prefix = "%s/%s/" % (outer, middle) |
|
92 |
directories.append(prefix) |
|
93 |
for filename in range(min(8, num_files - count)): |
|
94 |
count += 1 |
|
95 |
files.append(prefix + str(filename)) |
|
96 |
self.run_bzr('init') |
|
97 |
self.build_tree(directories + files) |
|
98 |
for d in directories: |
|
99 |
self.run_bzr('add', d) |
|
100 |
self.run_bzr('commit', '-m', 'initial repo layout') |
|
101 |
# create revisions
|
|
102 |
affected_files = files[:num_files_in_bundle] |
|
103 |
count = 0 |
|
104 |
for changes_file in range(num_revisions // num_files_in_bundle + 1): |
|
105 |
for f in affected_files: |
|
106 |
count += 1 |
|
107 |
if count >= num_revisions: |
|
108 |
break
|
|
109 |
content = "\n".join([str(i) for i in range(changes_file)] + |
|
110 |
[str(changes_file)] * 5) + "\n" |
|
111 |
self.build_tree_contents([(f, content)]) |
|
112 |
self.run_bzr("commit", '-m', 'some changes') |
|
113 |
assert count >= num_revisions |
|
114 |
||
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
115 |
def _time_read_write(self): |
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
116 |
branch, relpath = Branch.open_containing(".") |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
117 |
revision_history = branch.revision_history() |
118 |
bundle_text = StringIO() |
|
119 |
self.time(write_bundle, branch.repository, revision_history[-1], |
|
120 |
None, bundle_text) |
|
121 |
bundle_text.seek(0) |
|
122 |
self.time(read_bundle, bundle_text) |
|
123 |
||
124 |
def test_few_files_small_tree_1_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
125 |
self.make_parametrized_tree(5, 1, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
126 |
self._time_read_write() |
127 |
||
128 |
def test_few_files_small_tree_500_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
129 |
self.make_parametrized_tree(5, 500, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
130 |
self._time_read_write() |
131 |
||
132 |
def test_few_files_small_tree_1000_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
133 |
self.make_parametrized_tree(5, 1000, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
134 |
self._time_read_write() |
135 |
||
136 |
def test_few_files_moderate_tree_1_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
137 |
self.make_parametrized_tree(100, 1, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
138 |
self._time_read_write() |
139 |
||
140 |
def test_few_files_moderate_tree_500_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
141 |
self.make_parametrized_tree(100, 500, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
142 |
self._time_read_write() |
143 |
||
144 |
def test_few_files_moderate_tree_1000_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
145 |
self.make_parametrized_tree(100, 1000, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
146 |
self._time_read_write() |
147 |
||
148 |
def test_some_files_moderate_tree_1_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
149 |
self.make_parametrized_tree(100, 1, 100) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
150 |
self._time_read_write() |
151 |
||
152 |
def test_some_files_moderate_tree_500_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
153 |
self.make_parametrized_tree(100, 500, 100) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
154 |
self._time_read_write() |
155 |
||
156 |
def test_some_files_moderate_tree_1000_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
157 |
self.make_parametrized_tree(100, 1000, 100) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
158 |
self._time_read_write() |
159 |
||
160 |
def test_few_files_big_tree_1_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
161 |
self.make_parametrized_tree(1000, 1, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
162 |
self._time_read_write() |
163 |
||
164 |
def test_few_files_big_tree_500_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
165 |
self.make_parametrized_tree(1000, 500, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
166 |
self._time_read_write() |
167 |
||
168 |
def test_few_files_big_tree_1000_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
169 |
self.make_parametrized_tree(1000, 1000, 5) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
170 |
self._time_read_write() |
171 |
||
172 |
def test_some_files_big_tree_1_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
173 |
self.make_parametrized_tree(1000, 1, 100) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
174 |
self._time_read_write() |
175 |
||
176 |
def test_some_files_big_tree_500_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
177 |
self.make_parametrized_tree(1000, 500, 100) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
178 |
self._time_read_write() |
179 |
||
180 |
def test_some_files_big_tree_1000_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
181 |
self.make_parametrized_tree(1000, 1000, 100) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
182 |
self._time_read_write() |
183 |
||
184 |
def test_many_files_big_tree_1_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
185 |
self.make_parametrized_tree(1000, 1, 1000) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
186 |
self._time_read_write() |
187 |
||
188 |
def test_many_files_big_tree_500_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
189 |
self.make_parametrized_tree(1000, 500, 1000) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
190 |
self._time_read_write() |
191 |
||
192 |
def test_many_files_big_tree_1000_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
193 |
self.make_parametrized_tree(1000, 1000, 1000) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
194 |
self._time_read_write() |
195 |
||
196 |
||
197 |
if __name__ == '__main__': |
|
198 |
# USE the following if you want to regenerate the above test functions
|
|
|
1908.8.1
by Carl Friedrich Bolz
low level bundle tests. |
199 |
for treesize, treesize_h in [(5, "small"), (100, "moderate"), |
200 |
(1000, "big")]: |
|
201 |
for bundlefiles, bundlefiles_h in [(5, "few"), (100, "some"), |
|
202 |
(1000, "many")]: |
|
203 |
if bundlefiles > treesize: |
|
204 |
continue
|
|
205 |
for num_revisions in [1, 500, 1000]: |
|
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
206 |
code = """\ |
207 |
def test_%s_files_%s_tree_%s_revision(self): |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
208 |
self.make_parametrized_tree(%s, %s, %s) |
|
1908.3.8
by holger krekel
Explicitely generate test functions. |
209 |
self._time_read_write()
|
210 |
""" % (bundlefiles_h, treesize_h, num_revisions, |
|
211 |
treesize, num_revisions, bundlefiles) |
|
|
1908.3.12
by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of |
212 |
print code |
|
1908.8.3
by Carl Friedrich Bolz
(cfbolz, hpk): Add caching mechanism and add benchmark for bundle-reading. |
213 |