/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-30 19:44:06 UTC
  • mto: (1908.3.21 usecases-benchmarks)
  • mto: This revision was merged to the branch mainline in revision 2068.
  • Revision ID: cfbolz@gmx.de-20060830194406-969c5f912785214b
Fix problems pointed out by John:
  * Actually benchmark install_bundle too.
  * Fix PEP 8 issues.
  * Fix caching of trees by using names dependant on the parameters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
"""Tests for bzr bundle performance."""
17
17
 
 
18
from cStringIO import StringIO
18
19
import os
19
20
import shutil
20
 
from cStringIO import StringIO
21
21
 
 
22
from bzrlib import bzrdir
22
23
from bzrlib.add import smart_add
23
 
from bzrlib import bzrdir
24
24
from bzrlib.benchmarks import Benchmark
25
25
from bzrlib.branch import Branch
26
26
from bzrlib.bundle import read_bundle
 
27
from bzrlib.bundle.apply_bundle import install_bundle
27
28
from bzrlib.bundle.serializer import write_bundle
 
29
from bzrlib.revision import NULL_REVISION
28
30
from bzrlib.revisionspec import RevisionSpec
29
31
from bzrlib.workingtree import WorkingTree
30
32
 
31
33
 
32
34
class BundleBenchmark(Benchmark):
33
 
    """The bundle tests should (also) be done at a lower level with
34
 
    direct call to the bzrlib.
35
 
    """
 
35
    """Benchmarks for bzr bundle performance and bzr merge with a bundle."""
36
36
   
37
 
    def make_kernel_like_tree_committed(self):
38
 
        self.make_kernel_like_added_tree()
39
 
        self.run_bzr('commit', '-m', 'initial import')
40
 
 
41
37
    def test_create_bundle_known_kernel_like_tree(self):
42
38
        """Create a bundle for a kernel sized tree with no ignored, unknowns,
43
39
        or added and one commit.
59
55
        """Create a bundle for a kernel sized tree with no ignored, unknowns,
60
56
        or added and one commit.
61
57
        """ 
62
 
        self.make_kernel_like_tree_committed()
63
 
        f = file('../bundle', 'wb')
 
58
        tree = self.make_kernel_like_tree_committed('tree')
 
59
 
 
60
        f = open('bundle', 'wb')
64
61
        try:
65
 
            f.write(self.run_bzr('bundle', '--revision', '..-1')[0])
 
62
            write_bundle(tree.branch.repository, tree.last_revision(),
 
63
                         NULL_REVISION, f)
66
64
        finally:
67
65
            f.close()
68
 
        self.run_bzr("init", "../branch_a")
69
 
        os.chdir('../branch_a')
 
66
 
 
67
        tree2 = self.make_branch_and_tree('branch_a')
 
68
        os.chdir('branch_a')
70
69
        self.time(self.run_bzr, 'merge', '../bundle')
71
 
 
72
70
 
73
 
class BundleLibraryLevelBenchmark(Benchmark):
 
71
class BundleLibraryLevelWriteBenchmark(Benchmark):
 
72
    """ Benchmarks for the write_bundle library function. """
74
73
 
75
74
    def _time_read_write(self):
 
75
        print "timing"
76
76
        branch, relpath = Branch.open_containing("a")
77
77
        revision_history = branch.revision_history()
78
78
        bundle_text = StringIO()
 
79
        print "starting write bundle"
79
80
        self.time(write_bundle, branch.repository, revision_history[-1],
80
 
                  None, bundle_text)
 
81
                  NULL_REVISION, bundle_text)
 
82
        print "stopped writing bundle"
81
83
        bundle_text.seek(0)
82
 
        self.time(read_bundle, bundle_text)
 
84
        target_tree = self.make_branch_and_tree('b')
 
85
        print "starting reading bundle"
 
86
        bundle = self.time(read_bundle, bundle_text)
 
87
        print "starting installing bundle"
 
88
        self.time(install_bundle, target_tree.branch.repository, bundle)
83
89
 
84
90
    def test_few_files_small_tree_1_revision(self):
85
91
        os.mkdir("a")