/brz/remove-bazaar

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