/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
20
from bzrlib.tests import TestLoader
1714.1.4 by Robert Collins
Add new benchmarks for status and commit.
21
from bzrlib.tests.blackbox import ExternalBase
22
23
class Benchmark(ExternalBase):
24
1714.1.7 by Robert Collins
Review feedback.
25
    def make_kernel_like_tree(self):
1714.1.4 by Robert Collins
Add new benchmarks for status and commit.
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)
1707.2.2 by Robert Collins
Start on bench_add, an add benchtest.
42
43
44
def test_suite():
45
    """Build and return a TestSuite which contains benchmark tests only."""
46
    testmod_names = [ \
47
                   'bzrlib.benchmarks.bench_add',
1714.1.4 by Robert Collins
Add new benchmarks for status and commit.
48
                   'bzrlib.benchmarks.bench_checkout',
1714.1.5 by Robert Collins
Add commit benchmark.
49
                   'bzrlib.benchmarks.bench_commit',
1714.1.4 by Robert Collins
Add new benchmarks for status and commit.
50
                   'bzrlib.benchmarks.bench_status',
1707.2.2 by Robert Collins
Start on bench_add, an add benchtest.
51
                   ]
52
    return TestLoader().loadTestsFromModuleNames(testmod_names)