/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
"""Benchmark test suite for bzr."""
18
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
19
from bzrlib import (
20
    plugin,
21
    )
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
22
from bzrlib.tests.TestUtil import TestLoader
1714.1.4 by Robert Collins
Add new benchmarks for status and commit.
23
from bzrlib.tests.blackbox import ExternalBase
24
1841.1.1 by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests
25
1714.1.4 by Robert Collins
Add new benchmarks for status and commit.
26
class Benchmark(ExternalBase):
27
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
28
    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
29
                              link_working=False):
1725.2.5 by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop
30
        """Setup a temporary tree roughly like a kernel tree.
31
        
32
        :param url: Creat the kernel like tree as a lightweight checkout
33
        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
34
        :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
35
            just hardlink the working tree. Tests must request this, because
36
            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
37
        """
1908.2.16 by John Arbash Meinel
Move all the new TreeCreator classes into separate files.
38
        from bzrlib.benchmarks.tree_creator.kernel_like import (
39
            KernelLikeTreeCreator,
40
            )
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
41
        creator = KernelLikeTreeCreator(self, link_working=link_working,
42
                                        url=url)
43
        return creator.create(root=root)
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
44
1908.2.18 by John Arbash Meinel
I think it is actually better as simple helper functions on Benchmark
45
    def make_kernel_like_added_tree(self, root='.',
46
                                    link_working=True,
47
                                    hot_cache=True):
48
        """Make a kernel like tree, with all files added
49
50
        :param root: Where to create the files
51
        :param link_working: Instead of copying all of the working tree
52
            files, just hardlink them to the cached files. Tests can unlink
53
            files that they will change.
54
        :param hot_cache: Run through the newly created tree and make sure
55
            the stat-cache is correct. The old way of creating a freshly
56
            added tree always had a hot cache.
57
        """
58
        from bzrlib.benchmarks.tree_creator.kernel_like import (
59
            KernelLikeAddedTreeCreator,
60
            )
61
        creator = KernelLikeAddedTreeCreator(self, link_working=link_working,
62
                                             hot_cache=hot_cache)
63
        return creator.create(root=root)
64
65
    def make_kernel_like_committed_tree(self, root='.',
66
                                    link_working=True,
67
                                    link_bzr=False,
68
                                    hot_cache=True):
69
        """Make a kernel like tree, with all files added and committed
70
71
        :param root: Where to create the files
72
        :param link_working: Instead of copying all of the working tree
73
            files, just hardlink them to the cached files. Tests can unlink
74
            files that they will change.
75
        :param link_bzr: Hardlink the .bzr directory. For readonly 
76
            operations this is safe, and shaves off a lot of setup time
77
        """
78
        from bzrlib.benchmarks.tree_creator.kernel_like import (
79
            KernelLikeCommittedTreeCreator,
80
            )
81
        creator = KernelLikeCommittedTreeCreator(self,
82
                                                 link_working=link_working,
83
                                                 link_bzr=link_bzr,
84
                                                 hot_cache=hot_cache)
85
        return creator.create(root=root)
86
1934.1.16 by John Arbash Meinel
Add a cache for a kernel-like inventory
87
    def make_kernel_like_inventory(self):
88
        """Create an inventory with the properties of a kernel-like tree
89
90
        This should be equivalent to a committed kernel like tree, not
91
        just a working tree.
92
        """
93
        from bzrlib.benchmarks.tree_creator.kernel_like import (
94
            KernelLikeInventoryCreator,
95
            )
96
        creator = KernelLikeInventoryCreator(self)
97
        return creator.create()
98
1908.2.6 by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached
99
    def make_many_commit_tree(self, directory_name='.',
100
                              hardlink=False):
101
        """Create a tree with many commits.
102
        
103
        No file changes are included. Not hardlinking the working tree, 
104
        because there are no working tree files.
1756.2.19 by Aaron Bentley
Add benchmarks for merged trees
105
        """
1908.2.16 by John Arbash Meinel
Move all the new TreeCreator classes into separate files.
106
        from bzrlib.benchmarks.tree_creator.simple_many_commit import (
107
            SimpleManyCommitTreeCreator,
108
            )
1908.2.15 by John Arbash Meinel
Switching many_merge and heavy_merge to new tree creator classes
109
        creator = SimpleManyCommitTreeCreator(self, link_bzr=hardlink)
110
        return creator.create(root=directory_name)
1908.2.6 by John Arbash Meinel
Allow the many_merged and many_commit trees to be cached
111
112
    def make_heavily_merged_tree(self, directory_name='.',
113
                                 hardlink=False):
114
        """Create a tree in which almost every commit is a merge.
115
       
116
        No file changes are included.  This produces two trees, 
117
        one of which is returned.  Except for the first commit, every
118
        commit in its revision-history is a merge another commit in the other
119
        tree.  Not hardlinking the working tree, because there are no working 
120
        tree files.
121
        """
1908.2.16 by John Arbash Meinel
Move all the new TreeCreator classes into separate files.
122
        from bzrlib.benchmarks.tree_creator.heavily_merged import (
123
            HeavilyMergedTreeCreator,
124
            )
1908.2.15 by John Arbash Meinel
Switching many_merge and heavy_merge to new tree creator classes
125
        creator = HeavilyMergedTreeCreator(self, link_bzr=hardlink)
126
        return creator.create(root=directory_name)
1756.2.19 by Aaron Bentley
Add benchmarks for merged trees
127
1707.2.2 by Robert Collins
Start on bench_add, an add benchtest.
128
129
def test_suite():
130
    """Build and return a TestSuite which contains benchmark tests only."""
131
    testmod_names = [ \
132
                   'bzrlib.benchmarks.bench_add',
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
133
                   'bzrlib.benchmarks.bench_bench',
1911.2.3 by John Arbash Meinel
Moving everything into a new location so that we can cache more than just revision ids
134
                   'bzrlib.benchmarks.bench_cache_utf8',
1714.1.4 by Robert Collins
Add new benchmarks for status and commit.
135
                   'bzrlib.benchmarks.bench_checkout',
1714.1.5 by Robert Collins
Add commit benchmark.
136
                   'bzrlib.benchmarks.bench_commit',
1757.2.10 by Robert Collins
Give all inventory entries __slots__ that are useful with the current codebase.
137
                   'bzrlib.benchmarks.bench_inventory',
1756.1.7 by Aaron Bentley
Merge bzr.dev
138
                   'bzrlib.benchmarks.bench_log',
1756.1.2 by Aaron Bentley
Show logs using get_revisions
139
                   'bzrlib.benchmarks.bench_osutils',
1752.1.2 by Aaron Bentley
Benchmark the rocks command
140
                   'bzrlib.benchmarks.bench_rocks',
1714.1.4 by Robert Collins
Add new benchmarks for status and commit.
141
                   'bzrlib.benchmarks.bench_status',
1534.10.33 by Aaron Bentley
Add canonicalize_path benchmark
142
                   'bzrlib.benchmarks.bench_transform',
1732.1.11 by John Arbash Meinel
Trying multiple things to get WorkingTree.list_files time down
143
                   'bzrlib.benchmarks.bench_workingtree',
1934.1.1 by John Arbash Meinel
Write a benchmark for the XML serializer
144
                   'bzrlib.benchmarks.bench_xml',
1707.2.2 by Robert Collins
Start on bench_add, an add benchtest.
145
                   ]
1841.1.1 by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests
146
    suite = TestLoader().loadTestsFromModuleNames(testmod_names) 
147
148
    # Load any benchmarks from plugins
1711.2.78 by John Arbash Meinel
Cleanup the imports in bzrlib.benchmark
149
    for name, module in plugin.all_plugins().items():
150
        if getattr(module, 'bench_suite', None) is not None:
151
            suite.addTest(module.bench_suite())
1841.1.1 by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests
152
153
    return suite