/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
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 version 2 as published by
5
# the Free Software Foundation.
6
#
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
# GNU General Public License for more details.
11
#
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
16
"""Tests for bzr bundle performance."""
17
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
18
import os
1908.8.3 by Carl Friedrich Bolz
(cfbolz, hpk): Add caching mechanism and add benchmark for bundle-reading.
19
import shutil
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
20
from cStringIO import StringIO
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
21
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
22
from bzrlib.add import smart_add
23
from bzrlib import bzrdir
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
24
from bzrlib.benchmarks import Benchmark
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
25
from bzrlib.branch import Branch
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
26
from bzrlib.bundle import read_bundle
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
27
from bzrlib.bundle.serializer import write_bundle
28
from bzrlib.revisionspec import RevisionSpec
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
29
from bzrlib.workingtree import WorkingTree
30
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
31
32
class BundleBenchmark(Benchmark):
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
33
    """The bundle tests should (also) be done at a lower level with
34
    direct call to the bzrlib.
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
35
    """
1908.8.5 by holger krekel
route more creation code through cached_make
36
   
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
37
    def make_kernel_like_tree_committed(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
38
        self.make_kernel_like_added_tree()
1908.8.5 by holger krekel
route more creation code through cached_make
39
        self.run_bzr('commit', '-m', 'initial import')
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
40
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
41
    def test_create_bundle_known_kernel_like_tree(self):
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
42
        """Create a bundle for a kernel sized tree with no ignored, unknowns,
43
        or added and one commit.
44
        """ 
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
45
        self.make_kernel_like_committed_tree()
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
46
        self.time(self.run_bzr, 'bundle', '--revision', '..-1')
47
48
    def test_create_bundle_many_commit_tree (self):
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
49
        """Create a bundle for a tree with many commits but no changes.""" 
50
        self.make_many_commit_tree()
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
51
        self.time(self.run_bzr, 'bundle', '--revision', '..-1')
52
53
    def test_create_bundle_heavily_merged_tree(self):
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
54
        """Create a bundle for a heavily merged tree.""" 
55
        self.make_heavily_merged_tree()
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
56
        self.time(self.run_bzr, 'bundle', '--revision', '..-1')
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
57
        
1908.3.3 by Carl Friedrich Bolz
Add benchmark for applying a benchmark and fix some formatting/typos.
58
    def test_apply_bundle_known_kernel_like_tree(self):
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
59
        """Create a bundle for a kernel sized tree with no ignored, unknowns,
60
        or added and one commit.
61
        """ 
62
        self.make_kernel_like_tree_committed()
1908.3.3 by Carl Friedrich Bolz
Add benchmark for applying a benchmark and fix some formatting/typos.
63
        f = file('../bundle', 'wb')
64
        try:
65
            f.write(self.run_bzr('bundle', '--revision', '..-1')[0])
66
        finally:
67
            f.close()
1908.8.5 by holger krekel
route more creation code through cached_make
68
        self.run_bzr("init", "../branch_a")
1908.3.3 by Carl Friedrich Bolz
Add benchmark for applying a benchmark and fix some formatting/typos.
69
        os.chdir('../branch_a')
70
        self.time(self.run_bzr, 'merge', '../bundle')
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
71
1868.1.5 by Jan Balster
benchmarks for "bzr bundle --revision ..-1"
72
 
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
73
class BundleLibraryLevelBenchmark(Benchmark):
74
1908.3.8 by holger krekel
Explicitely generate test functions.
75
    def _time_read_write(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
76
        branch, relpath = Branch.open_containing("a")
1908.3.8 by holger krekel
Explicitely generate test functions.
77
        revision_history = branch.revision_history()
78
        bundle_text = StringIO()
79
        self.time(write_bundle, branch.repository, revision_history[-1],
80
                  None, bundle_text)
81
        bundle_text.seek(0)
82
        self.time(read_bundle, bundle_text)
83
84
    def test_few_files_small_tree_1_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
85
        os.mkdir("a")
86
        tree, files = self.create_with_commits(5, 1, directory_name="a")
87
        self.commit_some_revisions(tree, files[:5], 1, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
88
        self._time_read_write()
89
90
    def test_few_files_small_tree_500_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
91
        os.mkdir("a")
92
        tree, files = self.create_with_commits(5, 1, directory_name="a")
93
        self.commit_some_revisions(tree, files[:5], 500, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
94
        self._time_read_write()
95
96
    def test_few_files_small_tree_1000_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
97
        os.mkdir("a")
98
        tree, files = self.create_with_commits(5, 1, directory_name="a")
99
        self.commit_some_revisions(tree, files[:5], 1000, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
100
        self._time_read_write()
101
102
    def test_few_files_moderate_tree_1_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
103
        os.mkdir("a")
104
        tree, files = self.create_with_commits(100, 1, directory_name="a")
105
        self.commit_some_revisions(tree, files[:5], 1, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
106
        self._time_read_write()
107
108
    def test_few_files_moderate_tree_500_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
109
        os.mkdir("a")
110
        tree, files = self.create_with_commits(100, 1, directory_name="a")
111
        self.commit_some_revisions(tree, files[:5], 500, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
112
        self._time_read_write()
113
114
    def test_few_files_moderate_tree_1000_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
115
        os.mkdir("a")
116
        tree, files = self.create_with_commits(100, 1, directory_name="a")
117
        self.commit_some_revisions(tree, files[:5], 1000, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
118
        self._time_read_write()
119
120
    def test_some_files_moderate_tree_1_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
121
        os.mkdir("a")
122
        tree, files = self.create_with_commits(100, 1, directory_name="a")
123
        self.commit_some_revisions(tree, files[:100], 1, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
124
        self._time_read_write()
125
126
    def test_some_files_moderate_tree_500_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
127
        os.mkdir("a")
128
        tree, files = self.create_with_commits(100, 1, directory_name="a")
129
        self.commit_some_revisions(tree, files[:100], 500, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
130
        self._time_read_write()
131
132
    def test_some_files_moderate_tree_1000_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
133
        os.mkdir("a")
134
        tree, files = self.create_with_commits(100, 1, directory_name="a")
135
        self.commit_some_revisions(tree, files[:100], 1000, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
136
        self._time_read_write()
137
138
    def test_few_files_big_tree_1_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
139
        os.mkdir("a")
140
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
141
        self.commit_some_revisions(tree, files[:5], 1, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
142
        self._time_read_write()
143
144
    def test_few_files_big_tree_500_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
145
        os.mkdir("a")
146
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
147
        self.commit_some_revisions(tree, files[:5], 500, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
148
        self._time_read_write()
149
150
    def test_few_files_big_tree_1000_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
151
        os.mkdir("a")
152
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
153
        self.commit_some_revisions(tree, files[:5], 1000, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
154
        self._time_read_write()
155
156
    def test_some_files_big_tree_1_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
157
        os.mkdir("a")
158
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
159
        self.commit_some_revisions(tree, files[:100], 1, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
160
        self._time_read_write()
161
162
    def test_some_files_big_tree_500_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
163
        os.mkdir("a")
164
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
165
        self.commit_some_revisions(tree, files[:100], 500, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
166
        self._time_read_write()
167
168
    def test_some_files_big_tree_1000_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
169
        os.mkdir("a")
170
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
171
        self.commit_some_revisions(tree, files[:100], 1000, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
172
        self._time_read_write()
173
174
    def test_many_files_big_tree_1_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
175
        os.mkdir("a")
176
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
177
        self.commit_some_revisions(tree, files[:1000], 1, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
178
        self._time_read_write()
179
180
    def test_many_files_big_tree_500_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
181
        os.mkdir("a")
182
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
183
        self.commit_some_revisions(tree, files[:1000], 500, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
184
        self._time_read_write()
185
186
    def test_many_files_big_tree_1000_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
187
        os.mkdir("a")
188
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
189
        self.commit_some_revisions(tree, files[:1000], 1000, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
190
        self._time_read_write()
191
192
193
if __name__ == '__main__':
194
    # USE the following if you want to regenerate the above test functions 
1908.8.1 by Carl Friedrich Bolz
low level bundle tests.
195
    for treesize, treesize_h in [(5, "small"), (100, "moderate"),
196
                                 (1000, "big")]:
197
        for bundlefiles, bundlefiles_h in [(5, "few"), (100, "some"),
198
                                           (1000, "many")]:
199
            if bundlefiles > treesize:
200
                continue
201
            for num_revisions in [1, 500, 1000]:
1908.3.8 by holger krekel
Explicitely generate test functions.
202
                code = """\
203
    def test_%s_files_%s_tree_%s_revision(self):
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
204
        os.mkdir("a")
205
        tree, files = self.create_with_commits(%s, 1, directory_name="a")
206
        self.commit_some_revisions(tree, files[:%s], %s, 1)
1908.3.8 by holger krekel
Explicitely generate test functions.
207
        self._time_read_write()
208
""" % (bundlefiles_h, treesize_h, num_revisions,
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
209
       treesize, bundlefiles, num_revisions)
1908.3.12 by Carl Friedrich Bolz
Fix docstrings and other things to be PEP 8 compatible. Removed caching of
210
                print code
1908.8.3 by Carl Friedrich Bolz
(cfbolz, hpk): Add caching mechanism and add benchmark for bundle-reading.
211
1908.3.14 by Carl Friedrich Bolz
Refactor the bundle benchmarks to use the existing helper functions.
212