~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_bench.py

merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
"""Tests for bzr benchmark utilities performance."""
17
17
 
18
 
 
 
18
from bzrlib import (
 
19
    osutils,
 
20
    )
19
21
from bzrlib.benchmarks import Benchmark
 
22
from bzrlib.benchmarks.tree_creator.kernel_like import (
 
23
    KernelLikeTreeCreator,
 
24
    KernelLikeAddedTreeCreator,
 
25
    KernelLikeCommittedTreeCreator,
 
26
    )
 
27
from bzrlib.tests import TestSkipped
20
28
 
21
29
 
22
30
class MakeKernelLikeTreeBenchmark(Benchmark):
28
36
        # with AtomicFile tuning:                    2888ms/ 2926ms
29
37
        # switching to transport.append:             1468ms/ 2849ms
30
38
        self.time(self.make_kernel_like_tree)
 
39
 
 
40
    def test_02_make_kernel_like_tree(self):
 
41
        """Hardlinking a kernel-like working tree should be ~1s"""
 
42
        # make sure kernel_like_tree is cached
 
43
        creator = KernelLikeTreeCreator(self, link_working=True)
 
44
        if not creator.is_caching_enabled():
 
45
            raise TestSkipped('caching is disabled')
 
46
        creator.ensure_cached()
 
47
        self.time(creator.create, root='bar')
 
48
 
 
49
    def test_03_make_kernel_like_added_tree(self):
 
50
        """Time the first creation of a kernel like added tree"""
 
51
        creator = KernelLikeAddedTreeCreator(self)
 
52
        creator.disable_cache()
 
53
        self.time(creator.create, root='foo')
 
54
 
 
55
    def test_04_make_kernel_like_added_tree(self):
 
56
        """Time the second creation of a kernel like added tree 
 
57
        (this should be a clone)
 
58
        """
 
59
        # make sure kernel_like_added_tree is cached
 
60
        creator = KernelLikeAddedTreeCreator(self, link_working=True)
 
61
        if not creator.is_caching_enabled():
 
62
            # Caching is disabled, this test is meaningless
 
63
            raise TestSkipped('caching is disabled')
 
64
        creator.ensure_cached()
 
65
        self.time(creator.create, root='bar')
 
66
 
 
67
    def test_05_make_kernel_like_committed_tree(self):
 
68
        """Time the first creation of a committed kernel like tree"""
 
69
        creator = KernelLikeCommittedTreeCreator(self)
 
70
        creator.disable_cache()
 
71
        self.time(creator.create, root='foo')
 
72
 
 
73
    def test_06_make_kernel_like_committed_tree(self):
 
74
        """Time the second creation of a committed kernel like tree 
 
75
        (this should be a clone)
 
76
        """
 
77
        creator = KernelLikeCommittedTreeCreator(self,
 
78
                                                 link_working=True,
 
79
                                                 link_bzr=False)
 
80
        if not creator.is_caching_enabled():
 
81
            # Caching is disabled, this test is meaningless
 
82
            raise TestSkipped('caching is disabled')
 
83
        creator.ensure_cached()
 
84
        self.time(creator.create, root='bar')
 
85
 
 
86
    def test_07_make_kernel_like_committed_tree_hardlink(self):
 
87
        """Time the creation of a committed kernel like tree 
 
88
        (this should also hardlink the .bzr/ directory)
 
89
        """
 
90
        creator = KernelLikeCommittedTreeCreator(self,
 
91
                                                 link_working=True,
 
92
                                                 link_bzr=True)
 
93
        if not creator.is_caching_enabled():
 
94
            # Caching is disabled, this test is meaningless
 
95
            raise TestSkipped('caching is disabled')
 
96
        creator.ensure_cached()
 
97
        self.time(creator.create, root='bar')
 
98
 
 
99