~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_bundle.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-24 14:12:53 UTC
  • mto: This revision was merged to the branch mainline in revision 2095.
  • Revision ID: john@arbash-meinel.com-20061024141253-783fba812b197b70
(John Arbash Meinel) Update version information for 0.13 development

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.add import smart_add
25
25
from bzrlib.benchmarks import Benchmark
26
26
from bzrlib.branch import Branch
 
27
from bzrlib.bundle import read_bundle
27
28
from bzrlib.bundle.apply_bundle import install_bundle
28
 
from bzrlib.bundle.serializer import read_bundle, write_bundle
 
29
from bzrlib.bundle.serializer import write_bundle
29
30
from bzrlib.revision import NULL_REVISION
30
31
from bzrlib.revisionspec import RevisionSpec
31
32
from bzrlib.workingtree import WorkingTree
39
40
        or added and one commit.
40
41
        """ 
41
42
        self.make_kernel_like_committed_tree()
42
 
        self.time(self.run_bzr, ['bundle', '--revision', '..-1'])
 
43
        self.time(self.run_bzr, 'bundle', '--revision', '..-1')
43
44
 
44
45
    def test_create_bundle_many_commit_tree (self):
45
46
        """Create a bundle for a tree with many commits but no changes.""" 
46
47
        self.make_many_commit_tree()
47
 
        self.time(self.run_bzr, ['bundle', '--revision', '..-1'])
 
48
        self.time(self.run_bzr, 'bundle', '--revision', '..-1')
48
49
 
49
50
    def test_create_bundle_heavily_merged_tree(self):
50
51
        """Create a bundle for a heavily merged tree.""" 
51
52
        self.make_heavily_merged_tree()
52
 
        self.time(self.run_bzr, ['bundle', '--revision', '..-1'])
 
53
        self.time(self.run_bzr, 'bundle', '--revision', '..-1')
53
54
        
54
55
    def test_apply_bundle_known_kernel_like_tree(self):
55
56
        """Create a bundle for a kernel sized tree with no ignored, unknowns,
66
67
 
67
68
        tree2 = self.make_branch_and_tree('branch_a')
68
69
        os.chdir('branch_a')
69
 
        self.time(self.run_bzr, ['merge', '../bundle'])
 
70
        self.time(self.run_bzr, 'merge', '../bundle')
70
71
 
71
 
 
72
72
class BundleLibraryLevelWriteBenchmark(Benchmark):
73
73
    """ Benchmarks for the write_bundle library function. """
74
74
 
75
75
    def _time_read_write(self):
 
76
        print "timing"
76
77
        branch, relpath = Branch.open_containing("a")
77
78
        revision_history = branch.revision_history()
78
79
        bundle_text = StringIO()
 
80
        print "starting write bundle"
79
81
        self.time(write_bundle, branch.repository, revision_history[-1],
80
82
                  NULL_REVISION, bundle_text)
 
83
        print "stopped writing bundle"
81
84
        bundle_text.seek(0)
82
85
        target_tree = self.make_branch_and_tree('b')
 
86
        print "starting reading bundle"
83
87
        bundle = self.time(read_bundle, bundle_text)
 
88
        print "starting installing bundle"
84
89
        self.time(install_bundle, target_tree.branch.repository, bundle)
85
90
 
86
91
    def test_few_files_small_tree_1_revision(self):
95
100
        self.commit_some_revisions(tree, files[:5], 100, 1)
96
101
        self._time_read_write()
97
102
 
 
103
    def test_few_files_small_tree_1000_revision(self):
 
104
        os.mkdir("a")
 
105
        tree, files = self.create_with_commits(5, 1, directory_name="a")
 
106
        self.commit_some_revisions(tree, files[:5], 1000, 1)
 
107
        self._time_read_write()
 
108
 
98
109
    def test_few_files_moderate_tree_1_revision(self):
99
110
        os.mkdir("a")
100
111
        tree, files = self.create_with_commits(100, 1, directory_name="a")
107
118
        self.commit_some_revisions(tree, files[:5], 100, 1)
108
119
        self._time_read_write()
109
120
 
 
121
    def test_few_files_moderate_tree_1000_revision(self):
 
122
        os.mkdir("a")
 
123
        tree, files = self.create_with_commits(100, 1, directory_name="a")
 
124
        self.commit_some_revisions(tree, files[:5], 1000, 1)
 
125
        self._time_read_write()
 
126
 
110
127
    def test_some_files_moderate_tree_1_revision(self):
111
128
        os.mkdir("a")
112
129
        tree, files = self.create_with_commits(100, 1, directory_name="a")
113
130
        self.commit_some_revisions(tree, files[:100], 1, 1)
114
131
        self._time_read_write()
115
132
 
 
133
    def test_some_files_moderate_tree_100_revision(self):
 
134
        os.mkdir("a")
 
135
        tree, files = self.create_with_commits(100, 1, directory_name="a")
 
136
        self.commit_some_revisions(tree, files[:100], 100, 1)
 
137
        self._time_read_write()
 
138
 
 
139
    def test_some_files_moderate_tree_1000_revision(self):
 
140
        os.mkdir("a")
 
141
        tree, files = self.create_with_commits(100, 1, directory_name="a")
 
142
        self.commit_some_revisions(tree, files[:100], 1000, 1)
 
143
        self._time_read_write()
 
144
 
116
145
    def test_few_files_big_tree_1_revision(self):
117
146
        os.mkdir("a")
118
147
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
119
148
        self.commit_some_revisions(tree, files[:5], 1, 1)
120
149
        self._time_read_write()
121
150
 
 
151
    def test_few_files_big_tree_100_revision(self):
 
152
        os.mkdir("a")
 
153
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
154
        self.commit_some_revisions(tree, files[:5], 100, 1)
 
155
        self._time_read_write()
 
156
 
 
157
    def test_few_files_big_tree_1000_revision(self):
 
158
        os.mkdir("a")
 
159
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
160
        self.commit_some_revisions(tree, files[:5], 1000, 1)
 
161
        self._time_read_write()
 
162
 
122
163
    def test_some_files_big_tree_1_revision(self):
123
164
        os.mkdir("a")
124
165
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
125
166
        self.commit_some_revisions(tree, files[:100], 1, 1)
126
167
        self._time_read_write()
127
168
 
 
169
    def test_some_files_big_tree_100_revision(self):
 
170
        os.mkdir("a")
 
171
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
172
        self.commit_some_revisions(tree, files[:100], 100, 1)
 
173
        self._time_read_write()
 
174
 
 
175
    def test_some_files_big_tree_1000_revision(self):
 
176
        os.mkdir("a")
 
177
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
178
        self.commit_some_revisions(tree, files[:100], 1000, 1)
 
179
        self._time_read_write()
 
180
 
 
181
    def test_many_files_big_tree_1_revision(self):
 
182
        os.mkdir("a")
 
183
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
184
        self.commit_some_revisions(tree, files[:1000], 1, 1)
 
185
        self._time_read_write()
 
186
 
 
187
    def test_many_files_big_tree_100_revision(self):
 
188
        os.mkdir("a")
 
189
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
190
        self.commit_some_revisions(tree, files[:1000], 100, 1)
 
191
        self._time_read_write()
 
192
 
 
193
    def test_many_files_big_tree_1000_revision(self):
 
194
        os.mkdir("a")
 
195
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
196
        self.commit_some_revisions(tree, files[:1000], 1000, 1)
 
197
        self._time_read_write()
128
198
 
129
199
class BundleLibraryLevelInstallBenchmark(Benchmark):
130
200
    """ Benchmarks for the install_bundle library function. """
170
240
        self.commit_some_revisions(tree, files[:100], 1, 1)
171
241
        self._time_read_write()
172
242
 
 
243
    def test_some_files_moderate_tree_100_revision(self):
 
244
        os.mkdir("a")
 
245
        tree, files = self.create_with_commits(100, 1, directory_name="a")
 
246
        self.commit_some_revisions(tree, files[:100], 100, 1)
 
247
        self._time_read_write()
 
248
 
173
249
    def test_few_files_big_tree_1_revision(self):
174
250
        os.mkdir("a")
175
251
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
176
252
        self.commit_some_revisions(tree, files[:5], 1, 1)
177
253
        self._time_read_write()
178
254
 
 
255
    def test_few_files_big_tree_100_revision(self):
 
256
        os.mkdir("a")
 
257
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
258
        self.commit_some_revisions(tree, files[:5], 100, 1)
 
259
        self._time_read_write()
 
260
 
179
261
    def test_some_files_big_tree_1_revision(self):
180
262
        os.mkdir("a")
181
263
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
182
264
        self.commit_some_revisions(tree, files[:100], 1, 1)
183
265
        self._time_read_write()
184
266
 
 
267
    def test_some_files_big_tree_100_revision(self):
 
268
        os.mkdir("a")
 
269
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
270
        self.commit_some_revisions(tree, files[:100], 100, 1)
 
271
        self._time_read_write()
 
272
 
 
273
    def test_many_files_big_tree_1_revision(self):
 
274
        os.mkdir("a")
 
275
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
276
        self.commit_some_revisions(tree, files[:1000], 1, 1)
 
277
        self._time_read_write()
 
278
 
 
279
    def test_many_files_big_tree_100_revision(self):
 
280
        os.mkdir("a")
 
281
        tree, files = self.create_with_commits(1000, 1, directory_name="a")
 
282
        self.commit_some_revisions(tree, files[:1000], 100, 1)
 
283
        self._time_read_write()
 
284
 
185
285
 
186
286
if __name__ == '__main__':
187
287
    # USE the following if you want to regenerate the above test functions 
188
288
    for treesize, treesize_h in [(5, "small"), (100, "moderate"),
189
289
                                 (1000, "big")]:
190
 
        for bundlefiles, bundlefiles_h in [(5, "few"), (100, "some")]:
 
290
        for bundlefiles, bundlefiles_h in [(5, "few"), (100, "some"),
 
291
                                           (1000, "many")]:
191
292
            if bundlefiles > treesize:
192
293
                continue
193
 
            for num_revisions in [1, 100]:
194
 
                if (num_revisions >= 100 and 
195
 
                        (bundlefiles >= 100 or treesize >= 1000)):
196
 
                    # Skip the 100x100x? tests.
197
 
                    # And the 100x?x1000
198
 
                    continue
 
294
            for num_revisions in [1, 100, 1000]:
199
295
                code = """\
200
296
    def test_%s_files_%s_tree_%s_revision(self):
201
297
        os.mkdir("a")
206
302
       treesize, bundlefiles, num_revisions)
207
303
                print code
208
304
 
 
305
 
 
306