/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_bundle.py

  • Committer: Carl Friedrich Bolz
  • Date: 2006-08-10 11:28:41 UTC
  • mto: (1908.8.4 bzr.bundle_bench)
  • mto: This revision was merged to the branch mainline in revision 2068.
  • Revision ID: cfbolz@gmx.de-20060810112841-e9caf337a1a40637
low level bundle tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
"""Tests for bzr bundle performance."""
17
17
 
 
18
 
 
19
import os
 
20
from StringIO import StringIO
 
21
 
18
22
from bzrlib.benchmarks import Benchmark
 
23
from bzrlib.workingtree import WorkingTree
 
24
from bzrlib.branch import Branch
 
25
from bzrlib.bundle.serializer import write_bundle
 
26
from bzrlib.revisionspec import RevisionSpec
19
27
 
20
28
 
21
29
class BundleBenchmark(Benchmark):
23
31
    The bundle tests should (also) be done at a lower level with
24
32
    direct call to the bzrlib."""
25
33
    
 
34
 
26
35
    def test_create_bundle_known_kernel_like_tree(self):
27
36
        """
28
37
        Create a bundle for a kernel sized tree with no ignored, unknowns,
43
52
        Create a bundle for a heavily merged tree.""" 
44
53
        self.make_heavily_merged_tree()
45
54
        self.time(self.run_bzr, 'bundle', '--revision', '..-1')
46
 
 
 
55
        
47
56
    def test_apply_bundle_known_kernel_like_tree(self):
48
57
        """
49
58
        Create a bundle for a kernel sized tree with no ignored, unknowns,
60
69
            f.close()
61
70
        os.chdir('../branch_a')
62
71
        self.time(self.run_bzr, 'merge', '../bundle')
 
72
 
63
73
 
 
74
class BundleLibraryLevelBenchmark(Benchmark):
 
75
 
 
76
    def make_parametrized_tree(self, num_files, num_revisions,
 
77
                               num_files_in_bundle):
 
78
        """Create a tree with given parameters. Always creates 2 levels of
 
79
        directories with the given number of files. Then the given number of
 
80
        revisions are created, changing some lines in one files in each
 
81
        revision. Only num_files_in_bundle files are changed in these
 
82
        revisions.
 
83
 
 
84
        :param num_files: number of files in tree
 
85
        :param num_revisions: number of revisions
 
86
        :param num_files_in_bundle: number of files changed in the revisions
 
87
        """
 
88
        # create files
 
89
        directories = []
 
90
        files = []
 
91
        count = 0
 
92
        for outer in range(num_files // 64 + 1):
 
93
            directories.append("%s/" % outer)
 
94
            for middle in range(8):
 
95
                prefix = "%s/%s/" % (outer, middle)
 
96
                directories.append(prefix)
 
97
                for filename in range(min(8, num_files - count)):
 
98
                    count += 1
 
99
                    files.append(prefix + str(filename))
 
100
        self.run_bzr('init')
 
101
        self.build_tree(directories + files)
 
102
        for d in directories:
 
103
            self.run_bzr('add', d)
 
104
        self.run_bzr('commit', '-m', 'initial repo layout')
 
105
        # create revisions
 
106
        affected_files = files[:num_files_in_bundle]
 
107
        count = 0
 
108
        for changes_file in range(num_revisions // num_files_in_bundle + 1):
 
109
            for f in affected_files:
 
110
                count += 1
 
111
                if count >= num_revisions:
 
112
                    break
 
113
                content = "\n".join([str(i) for i in range(changes_file)] +
 
114
                                    [str(changes_file)] * 5) + "\n"
 
115
                self.build_tree_contents([(f, content)])
 
116
                self.run_bzr("commit", '-m', 'some changes')
 
117
        assert count >= num_revisions
 
118
 
 
119
    for treesize, treesize_h in [(5, "small"), (100, "moderate"),
 
120
                                 (1000, "big")]:
 
121
        for bundlefiles, bundlefiles_h in [(5, "few"), (100, "some"),
 
122
                                           (1000, "many")]:
 
123
            if bundlefiles > treesize:
 
124
                continue
 
125
            for num_revisions in [1, 500, 1000]:
 
126
                code = """
 
127
def test_%s_files_%s_tree_%s_revision(self):
 
128
    self.make_parametrized_tree(%s, %s, %s)
 
129
    branch, _ = Branch.open_containing(".")
 
130
    revision_history = branch.revision_history()
 
131
    bundle_text = StringIO()
 
132
    self.time(write_bundle, branch.repository, revision_history[-1],
 
133
              None, bundle_text)""" % (
 
134
                    bundlefiles_h, treesize_h, num_revisions,
 
135
                    treesize, num_revisions, bundlefiles)
 
136
              #exec code