~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_bench.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-14 23:49:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1923.
  • Revision ID: john@arbash-meinel.com-20060814234901-a0e0ee48197703e1
Change caching logic. Don't cache at all without --cache-dir being supplied

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    osutils,
20
20
    )
21
21
from bzrlib.benchmarks import Benchmark
 
22
from bzrlib.tests import TestSkipped
22
23
 
23
24
 
24
25
class MakeKernelLikeTreeBenchmark(Benchmark):
25
26
 
26
 
    def test_01_make_kernel_like_tree(self):
 
27
    def test_make_kernel_like_tree(self):
27
28
        """Making a kernel sized tree should be ~ 5seconds on modern disk.""" 
28
29
        # on roberts machine: this originally took:  7372ms/ 7479ms
29
30
        # with the LocalTransport._abspath call:     3730ms/ 3778ms
34
35
    def test_02_make_kernel_like_tree(self):
35
36
        """Hardlinking a kernel-like working tree should be ~1s"""
36
37
        # make sure kernel_like_tree is cached
37
 
        self._cache_kernel_like_tree()
 
38
        cache_dir, is_cached = self.get_cache_dir('kernel_like_tree')
 
39
        if cache_dir is None:
 
40
            # Caching is disabled, this test is meaningless
 
41
            raise TestSkipped('caching is disabled')
 
42
        if not is_cached:
 
43
            # If it has not been cached yet, create it
 
44
            self.make_kernel_like_tree(root='foo', link_working=True)
38
45
        self.time(self.make_kernel_like_tree, root='bar',
39
 
                  hardlink_working=True)
 
46
                  link_working=True)
40
47
 
41
48
    def test_03_make_kernel_like_added_tree(self):
42
49
        """Time the first creation of a kernel like added tree"""
44
51
        try:
45
52
            # Change to a local cache directory so we know this
46
53
            # really creates the files
47
 
            Benchmark.CACHE_ROOT = osutils.abspath('cache')
 
54
            Benchmark.CACHE_ROOT = None
48
55
            self.time(self.make_kernel_like_added_tree, root='foo')
49
56
        finally:
50
57
            Benchmark.CACHE_ROOT = orig_cache
54
61
        (this should be a clone)
55
62
        """
56
63
        # make sure kernel_like_added_tree is cached
57
 
        self._cache_kernel_like_added_tree()
 
64
        cache_dir, is_cached = self.get_cache_dir('kernel_like_added_tree')
 
65
        if cache_dir is None:
 
66
            # Caching is disabled, this test is meaningless
 
67
            raise TestSkipped('caching is disabled')
 
68
        if not is_cached:
 
69
            # If it has not been cached yet, create it
 
70
            self.make_kernel_like_added_tree(root='foo')
58
71
        self.time(self.make_kernel_like_added_tree, root='bar')
59
72
 
60
73
    def test_05_make_kernel_like_committed_tree(self):
63
76
        try:
64
77
            # Change to a local cache directory so we know this
65
78
            # really creates the files
66
 
            Benchmark.CACHE_ROOT = osutils.abspath('cache')
 
79
            Benchmark.CACHE_ROOT = None
67
80
            self.time(self.make_kernel_like_committed_tree, root='foo')
68
81
        finally:
69
82
            Benchmark.CACHE_ROOT = orig_cache
73
86
        (this should be a clone)
74
87
        """
75
88
        # Call make_kernel_like_committed_tree to make sure it is cached
76
 
        self._cache_kernel_like_committed_tree()
 
89
        cache_dir, is_cached = self.get_cache_dir('kernel_like_committed_tree')
 
90
        if cache_dir is None:
 
91
            raise TestSkipped('caching is disabled')
 
92
        if not is_cached:
 
93
            self.make_kernel_like_committed_tree(root='foo')
77
94
        self.time(self.make_kernel_like_committed_tree, root='bar')
78
95
 
79
96
    def test_07_make_kernel_like_committed_tree_hardlink(self):
81
98
        (this should also hardlink the .bzr/ directory)
82
99
        """
83
100
        # make sure kernel_like_committed_tree is cached
84
 
        self._cache_kernel_like_committed_tree()
 
101
        cache_dir, is_cached = self.get_cache_dir('kernel_like_committed_tree')
 
102
        if cache_dir is None:
 
103
            raise TestSkipped('caching is disabled')
 
104
        if not is_cached:
 
105
            self.make_kernel_like_committed_tree(root='foo')
85
106
        self.time(self.make_kernel_like_committed_tree, root='bar',
86
 
                    hardlink_bzr=True)
 
107
                    link_bzr=True)
87
108
 
88
109