bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1707.2.2
by Robert Collins
Start on bench_add, an add benchtest. |
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 as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
||
18 |
"""Benchmark test suite for bzr."""
|
|
19 |
||
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
20 |
import os |
21 |
import shutil |
|
22 |
||
23 |
from bzrlib import ( |
|
24 |
add, |
|
25 |
bzrdir, |
|
26 |
osutils, |
|
27 |
plugin, |
|
28 |
workingtree, |
|
29 |
)
|
|
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
30 |
from bzrlib.tests.TestUtil import TestLoader |
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
31 |
from bzrlib.tests.blackbox import ExternalBase |
32 |
||
|
1841.1.1
by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests |
33 |
|
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
34 |
class Benchmark(ExternalBase): |
35 |
||
|
1908.2.4
by John Arbash Meinel
Add the ability to specify a benchmark cache directory. |
36 |
CACHE_ROOT = None |
37 |
||
38 |
def get_cache_dir(self, extra): |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
39 |
"""Get the directory to use for caching the given object. |
|
1908.2.4
by John Arbash Meinel
Add the ability to specify a benchmark cache directory. |
40 |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
41 |
:return: (cache_dir, is_cached)
|
42 |
cache_dir: The path to use for caching. If None, caching is disabled
|
|
43 |
is_cached: Has the path already been created?
|
|
44 |
"""
|
|
|
1908.2.4
by John Arbash Meinel
Add the ability to specify a benchmark cache directory. |
45 |
if Benchmark.CACHE_ROOT is None: |
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
46 |
return None, False |
|
1908.2.4
by John Arbash Meinel
Add the ability to specify a benchmark cache directory. |
47 |
if not os.path.isdir(Benchmark.CACHE_ROOT): |
48 |
os.mkdir(Benchmark.CACHE_ROOT) |
|
49 |
cache_dir = osutils.pathjoin(self.CACHE_ROOT, extra) |
|
50 |
return cache_dir, os.path.exists(cache_dir) |
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
51 |
|
52 |
def make_kernel_like_tree(self, url=None, root='.', |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
53 |
link_working=False): |
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
54 |
"""Setup a temporary tree roughly like a kernel tree. |
55 |
|
|
56 |
:param url: Creat the kernel like tree as a lightweight checkout
|
|
57 |
of a new branch created at url.
|
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
58 |
:param link_working: instead of creating a new copy of all files
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
59 |
just hardlink the working tree. Tests must request this, because
|
60 |
they must break links if they want to change the files
|
|
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
61 |
"""
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
62 |
if url is not None: |
63 |
b = bzrdir.BzrDir.create_branch_convenience(url) |
|
64 |
d = bzrdir.BzrDir.create(root) |
|
65 |
bzrlib.branch.BranchReferenceFormat().initialize(d, b) |
|
66 |
tree = d.create_workingtree() |
|
67 |
else: |
|
68 |
tree = bzrdir.BzrDir.create_standalone_workingtree(root) |
|
69 |
||
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
70 |
self._link_or_copy_kernel_files(root=root, do_link=link_working) |
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
71 |
return tree |
72 |
||
73 |
def _make_kernel_files(self, root='.'): |
|
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
74 |
# a kernel tree has ~10000 and 500 directory, with most files around
|
75 |
# 3-4 levels deep.
|
|
76 |
# we simulate this by three levels of dirs named 0-7, givin 512 dirs,
|
|
77 |
# and 20 files each.
|
|
78 |
files = [] |
|
79 |
for outer in range(8): |
|
80 |
files.append("%s/" % outer) |
|
81 |
for middle in range(8): |
|
82 |
files.append("%s/%s/" % (outer, middle)) |
|
83 |
for inner in range(8): |
|
84 |
prefix = "%s/%s/%s/" % (outer, middle, inner) |
|
85 |
files.append(prefix) |
|
86 |
files.extend([prefix + str(foo) for foo in range(20)]) |
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
87 |
cwd = osutils.getcwd() |
88 |
os.chdir(root) |
|
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
89 |
self.build_tree(files) |
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
90 |
os.chdir(cwd) |
91 |
||
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
92 |
def _cache_kernel_like_tree(self): |
93 |
"""Create the kernel_like_tree cache dir if it doesn't exist""" |
|
94 |
cache_dir, is_cached = self.get_cache_dir('kernel_like_tree') |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
95 |
if cache_dir is None: |
96 |
return None |
|
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
97 |
if is_cached: |
98 |
return cache_dir |
|
99 |
os.mkdir(cache_dir) |
|
100 |
self._make_kernel_files(root=cache_dir) |
|
101 |
self._protect_files(cache_dir) |
|
102 |
return cache_dir |
|
103 |
||
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
104 |
def _link_or_copy_kernel_files(self, root, do_link=True): |
105 |
"""Hardlink the kernel files from the cached location. |
|
106 |
||
107 |
If the platform doesn't correctly support hardlinking files, it
|
|
108 |
reverts to just creating new ones.
|
|
109 |
"""
|
|
110 |
||
111 |
if not osutils.hardlinks_good() or not do_link: |
|
112 |
# Turns out that 'shutil.copytree()' is no faster than
|
|
113 |
# just creating them. Probably the python overhead.
|
|
114 |
# Plain _make_kernel_files takes 5s
|
|
115 |
# cp -a takes 3s
|
|
116 |
# using hardlinks takes < 1s.
|
|
117 |
self._make_kernel_files(root=root) |
|
118 |
return
|
|
119 |
||
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
120 |
cache_dir = self._cache_kernel_like_tree() |
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
121 |
if cache_dir is None: |
122 |
self._make_kernel_files(root=root) |
|
123 |
return
|
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
124 |
|
125 |
# Hardlinking the target directory is *much* faster (7s => <1s).
|
|
|
1908.2.4
by John Arbash Meinel
Add the ability to specify a benchmark cache directory. |
126 |
osutils.copy_tree(cache_dir, root, |
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
127 |
handlers={'file':os.link}) |
128 |
||
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
129 |
def _clone_tree(self, source, dest, link_bzr=False, link_working=True, |
130 |
hot_cache=True): |
|
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
131 |
"""Copy the contents from a given location to another location. |
132 |
Optionally hardlink certain pieces of the tree.
|
|
133 |
||
134 |
:param source: The directory to copy
|
|
135 |
:param dest: The destination
|
|
136 |
:param link_bzr: Should the .bzr/ files be hardlinked?
|
|
137 |
:param link_working: Should the working tree be hardlinked?
|
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
138 |
:param hot_cache: Update the hash-cache when you are done
|
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
139 |
"""
|
140 |
# We use shutil.copyfile so that we don't copy permissions
|
|
141 |
# because most of our source trees are marked readonly to
|
|
142 |
# prevent modifying in the case of hardlinks
|
|
143 |
handlers = {'file':shutil.copyfile} |
|
144 |
if osutils.hardlinks_good(): |
|
145 |
if link_working: |
|
146 |
if link_bzr: |
|
147 |
handlers = {'file':os.link} |
|
148 |
else: |
|
149 |
# Don't hardlink files inside bzr
|
|
150 |
def file_handler(source, dest): |
|
151 |
if '.bzr/' in source: |
|
152 |
shutil.copyfile(source, dest) |
|
153 |
else: |
|
154 |
os.link(source, dest) |
|
155 |
handlers = {'file':file_handler} |
|
156 |
elif link_bzr: |
|
157 |
# Only link files inside .bzr/
|
|
158 |
def file_handler(source, dest): |
|
159 |
if '.bzr/' in source: |
|
160 |
os.link(source, dest) |
|
161 |
else: |
|
162 |
shutil.copyfile(source, dest) |
|
163 |
handlers = {'file':file_handler} |
|
164 |
osutils.copy_tree(source, dest, handlers=handlers) |
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
165 |
tree = workingtree.WorkingTree.open(dest) |
166 |
if hot_cache: |
|
167 |
tree.lock_write() |
|
168 |
try: |
|
169 |
# tree._hashcache.scan() just checks and removes
|
|
170 |
# entries that are out of date
|
|
171 |
# we need to actually store new ones
|
|
172 |
for path, ie in tree.inventory.iter_entries_by_dir(): |
|
173 |
tree.get_file_sha1(ie.file_id, path) |
|
174 |
finally: |
|
175 |
tree.unlock() |
|
176 |
# If we didn't iterate the tree, the hash cache is technically
|
|
177 |
# invalid, and it would be better to remove it, but there is
|
|
178 |
# no public api for that.
|
|
179 |
return tree |
|
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
180 |
|
181 |
def _protect_files(self, root): |
|
182 |
"""Chmod all files underneath 'root' to prevent writing |
|
183 |
||
184 |
:param root: The base directory to modify
|
|
185 |
"""
|
|
186 |
for dirinfo, entries in osutils.walkdirs(root): |
|
187 |
for relpath, name, kind, st, abspath in entries: |
|
188 |
if kind == 'file': |
|
189 |
os.chmod(abspath, 0440) |
|
190 |
||
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
191 |
def _create_kernel_like_added_tree(self, root, in_cache=False): |
192 |
"""Create a kernel-like tree with the all files added |
|
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
193 |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
194 |
:param root: The root directory to create the files
|
195 |
:param in_cache: Is this being created in the cache dir?
|
|
196 |
"""
|
|
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
197 |
# Get a basic tree with working files
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
198 |
tree = self.make_kernel_like_tree(root=root, |
199 |
link_working=in_cache) |
|
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
200 |
# Add everything to it
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
201 |
tree.lock_write() |
202 |
try: |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
203 |
add.smart_add_tree(tree, [root], recurse=True, save=True) |
204 |
if in_cache: |
|
205 |
self._protect_files(root+'/.bzr') |
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
206 |
finally: |
207 |
tree.unlock() |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
208 |
return tree |
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
209 |
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
210 |
def make_kernel_like_added_tree(self, root='.', |
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
211 |
link_working=True, |
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
212 |
hot_cache=True): |
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
213 |
"""Make a kernel like tree, with all files added |
214 |
||
215 |
:param root: Where to create the files
|
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
216 |
:param link_working: Instead of copying all of the working tree
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
217 |
files, just hardlink them to the cached files. Tests can unlink
|
218 |
files that they will change.
|
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
219 |
:param hot_cache: Run through the newly created tree and make sure
|
220 |
the stat-cache is correct. The old way of creating a freshly
|
|
221 |
added tree always had a hot cache.
|
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
222 |
"""
|
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
223 |
# There isn't much underneath .bzr, so we don't support hardlinking
|
224 |
# it. Testing showed there wasn't much gain, and there is potentially
|
|
225 |
# a problem if someone modifies something underneath us.
|
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
226 |
cache_dir, is_cached = self.get_cache_dir('kernel_like_added_tree') |
227 |
if cache_dir is None: |
|
228 |
# Not caching
|
|
229 |
return self._create_kernel_like_added_tree(root, in_cache=False) |
|
230 |
||
231 |
if not is_cached: |
|
232 |
self._create_kernel_like_added_tree(root=cache_dir, |
|
233 |
in_cache=True) |
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
234 |
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
235 |
return self._clone_tree(cache_dir, root, |
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
236 |
link_working=link_working, |
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
237 |
hot_cache=hot_cache) |
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
238 |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
239 |
def _create_kernel_like_committed_tree(self, root, in_cache=False): |
240 |
"""Create a kernel-like tree with all files added and committed""" |
|
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
241 |
# Get a basic tree with working files
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
242 |
tree = self.make_kernel_like_added_tree(root=root, |
243 |
link_working=in_cache, |
|
244 |
hot_cache=(not in_cache)) |
|
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
245 |
tree.commit('first post', rev_id='r1') |
246 |
||
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
247 |
if in_cache: |
248 |
self._protect_files(root+'/.bzr') |
|
249 |
return tree |
|
|
1908.2.5
by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test |
250 |
|
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
251 |
def make_kernel_like_committed_tree(self, root='.', |
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
252 |
link_working=True, |
253 |
link_bzr=False, |
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
254 |
hot_cache=True): |
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
255 |
"""Make a kernel like tree, with all files added and committed |
256 |
||
257 |
:param root: Where to create the files
|
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
258 |
:param link_working: Instead of copying all of the working tree
|
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
259 |
files, just hardlink them to the cached files. Tests can unlink
|
260 |
files that they will change.
|
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
261 |
:param link_bzr: Hardlink the .bzr directory. For readonly
|
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
262 |
operations this is safe, and shaves off a lot of setup time
|
263 |
"""
|
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
264 |
cache_dir, is_cached = self.get_cache_dir('kernel_like_committed_tree') |
265 |
if cache_dir is None: |
|
266 |
return self._create_kernel_like_committed_tree(root=root, |
|
267 |
in_cache=False) |
|
268 |
||
269 |
if not is_cached: |
|
270 |
self._create_kernel_like_committed_tree(root=cache_dir, |
|
271 |
in_cache=True) |
|
|
1908.2.3
by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly. |
272 |
|
|
1908.2.2
by John Arbash Meinel
Allow caching basic kernel-like trees |
273 |
# Now we have a cached tree, just copy it
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
274 |
return self._clone_tree(cache_dir, root, |
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
275 |
link_bzr=link_bzr, |
276 |
link_working=link_working, |
|
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
277 |
hot_cache=hot_cache) |
|
1707.2.2
by Robert Collins
Start on bench_add, an add benchtest. |
278 |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
279 |
def _create_many_commit_tree(self, root, in_cache=False): |
280 |
tree = bzrdir.BzrDir.create_standalone_workingtree(root) |
|
|
1756.1.2
by Aaron Bentley
Show logs using get_revisions |
281 |
tree.lock_write() |
282 |
try: |
|
283 |
for i in xrange(1000): |
|
284 |
tree.commit('no-changes commit %d' % i) |
|
285 |
finally: |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
286 |
tree.unlock() |
287 |
if in_cache: |
|
288 |
self._protect_files(root+'/.bzr') |
|
|
1908.2.6
by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached |
289 |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
290 |
return tree |
|
1908.2.6
by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached |
291 |
|
292 |
def make_many_commit_tree(self, directory_name='.', |
|
293 |
hardlink=False): |
|
294 |
"""Create a tree with many commits. |
|
295 |
|
|
296 |
No file changes are included. Not hardlinking the working tree,
|
|
297 |
because there are no working tree files.
|
|
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
298 |
"""
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
299 |
cache_dir, is_cached = self.get_cache_dir('many_commit_tree') |
300 |
if cache_dir is None: |
|
301 |
return self._create_many_commit_tree(root=directory_name, |
|
302 |
in_cache=False) |
|
303 |
||
304 |
if not is_cached: |
|
305 |
self._create_many_commit_tree(root=cache_dir, in_cache=True) |
|
306 |
||
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
307 |
return self._clone_tree(cache_dir, directory_name, |
308 |
link_bzr=hardlink, |
|
309 |
hot_cache=True) |
|
|
1908.2.6
by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached |
310 |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
311 |
def _create_heavily_merged_tree(self, root, in_cache=False): |
312 |
os.mkdir(root) |
|
|
1908.2.6
by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached |
313 |
tree = bzrdir.BzrDir.create_standalone_workingtree( |
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
314 |
root + '/tree1') |
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
315 |
tree.lock_write() |
316 |
try: |
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
317 |
tree2 = tree.bzrdir.sprout(root + '/tree2').open_workingtree() |
|
1756.2.21
by Aaron Bentley
Clean up merge log benchmark |
318 |
tree2.lock_write() |
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
319 |
try: |
|
1756.2.21
by Aaron Bentley
Clean up merge log benchmark |
320 |
for i in xrange(250): |
321 |
revision_id = tree.commit('no-changes commit %d-a' % i) |
|
322 |
tree2.branch.fetch(tree.branch, revision_id) |
|
323 |
tree2.set_pending_merges([revision_id]) |
|
324 |
revision_id = tree2.commit('no-changes commit %d-b' % i) |
|
325 |
tree.branch.fetch(tree2.branch, revision_id) |
|
326 |
tree.set_pending_merges([revision_id]) |
|
327 |
tree.set_pending_merges([]) |
|
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
328 |
finally: |
|
1908.2.6
by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached |
329 |
tree2.unlock() |
|
1756.2.21
by Aaron Bentley
Clean up merge log benchmark |
330 |
finally: |
|
1908.2.6
by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached |
331 |
tree.unlock() |
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
332 |
if in_cache: |
333 |
self._protect_files(root+'/tree1/.bzr') |
|
334 |
return tree |
|
|
1908.2.6
by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached |
335 |
|
336 |
def make_heavily_merged_tree(self, directory_name='.', |
|
337 |
hardlink=False): |
|
338 |
"""Create a tree in which almost every commit is a merge. |
|
339 |
|
|
340 |
No file changes are included. This produces two trees,
|
|
341 |
one of which is returned. Except for the first commit, every
|
|
342 |
commit in its revision-history is a merge another commit in the other
|
|
343 |
tree. Not hardlinking the working tree, because there are no working
|
|
344 |
tree files.
|
|
345 |
"""
|
|
|
1908.2.11
by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied |
346 |
cache_dir, is_cached = self.get_cache_dir('heavily_merged_tree') |
347 |
if cache_dir is None: |
|
348 |
# Not caching
|
|
349 |
return self._create_heavily_merged_tree(root=directory_name, |
|
350 |
in_cache=False) |
|
351 |
||
352 |
if not is_cached: |
|
353 |
self._create_heavily_merged_tree(root=cache_dir, in_cache=True) |
|
354 |
||
|
1908.2.6
by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached |
355 |
tree_dir = cache_dir + '/tree1' |
|
1908.2.9
by John Arbash Meinel
Allow pre-warming the hash-cache |
356 |
return self._clone_tree(tree_dir, directory_name, |
357 |
link_bzr=hardlink, |
|
358 |
hot_cache=True) |
|
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
359 |
|
|
1707.2.2
by Robert Collins
Start on bench_add, an add benchtest. |
360 |
|
361 |
def test_suite(): |
|
362 |
"""Build and return a TestSuite which contains benchmark tests only.""" |
|
363 |
testmod_names = [ \ |
|
364 |
'bzrlib.benchmarks.bench_add', |
|
|
1755.2.1
by Robert Collins
Add a benchmark for make_kernel_like_tree. |
365 |
'bzrlib.benchmarks.bench_bench', |
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
366 |
'bzrlib.benchmarks.bench_checkout', |
|
1714.1.5
by Robert Collins
Add commit benchmark. |
367 |
'bzrlib.benchmarks.bench_commit', |
|
1757.2.10
by Robert Collins
Give all inventory entries __slots__ that are useful with the current codebase. |
368 |
'bzrlib.benchmarks.bench_inventory', |
|
1756.1.7
by Aaron Bentley
Merge bzr.dev |
369 |
'bzrlib.benchmarks.bench_log', |
|
1756.1.2
by Aaron Bentley
Show logs using get_revisions |
370 |
'bzrlib.benchmarks.bench_osutils', |
|
1752.1.2
by Aaron Bentley
Benchmark the rocks command |
371 |
'bzrlib.benchmarks.bench_rocks', |
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
372 |
'bzrlib.benchmarks.bench_status', |
|
1534.10.33
by Aaron Bentley
Add canonicalize_path benchmark |
373 |
'bzrlib.benchmarks.bench_transform', |
|
1732.1.11
by John Arbash Meinel
Trying multiple things to get WorkingTree.list_files time down |
374 |
'bzrlib.benchmarks.bench_workingtree', |
|
1707.2.2
by Robert Collins
Start on bench_add, an add benchtest. |
375 |
]
|
|
1841.1.1
by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests |
376 |
suite = TestLoader().loadTestsFromModuleNames(testmod_names) |
377 |
||
378 |
# Load any benchmarks from plugins
|
|
|
1711.2.78
by John Arbash Meinel
Cleanup the imports in bzrlib.benchmark |
379 |
for name, module in plugin.all_plugins().items(): |
380 |
if getattr(module, 'bench_suite', None) is not None: |
|
381 |
suite.addTest(module.bench_suite()) |
|
|
1841.1.1
by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests |
382 |
|
383 |
return suite |