~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/__init__.py

Add new benchmarks for status and commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""Benchmark test suite for bzr."""
19
19
 
20
20
from bzrlib.tests import TestLoader
 
21
from bzrlib.tests.blackbox import ExternalBase
 
22
 
 
23
class Benchmark(ExternalBase):
 
24
 
 
25
    def make_kernel_tree(self):
 
26
        """Setup a temporary tree roughly like a kernel tree."""
 
27
        # a kernel tree has ~10000 and 500 directory, with most files around 
 
28
        # 3-4 levels deep. 
 
29
        # we simulate this by three levels of dirs named 0-7, givin 512 dirs,
 
30
        # and 20 files each.
 
31
        self.run_bzr('init')
 
32
        files = []
 
33
        for outer in range(8):
 
34
            files.append("%s/" % outer)
 
35
            for middle in range(8):
 
36
                files.append("%s/%s/" % (outer, middle))
 
37
                for inner in range(8):
 
38
                    prefix = "%s/%s/%s/" % (outer, middle, inner)
 
39
                    files.append(prefix)
 
40
                    files.extend([prefix + str(foo) for foo in range(20)])
 
41
        self.build_tree(files)
21
42
 
22
43
 
23
44
def test_suite():
24
45
    """Build and return a TestSuite which contains benchmark tests only."""
25
46
    testmod_names = [ \
26
47
                   'bzrlib.benchmarks.bench_add',
 
48
                   'bzrlib.benchmarks.bench_checkout',
 
49
                   'bzrlib.benchmarks.bench_status',
27
50
                   ]
28
51
    return TestLoader().loadTestsFromModuleNames(testmod_names)