~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-07 21:26:25 UTC
  • mto: (1908.4.6 commit-perf)
  • mto: This revision was merged to the branch mainline in revision 1923.
  • Revision ID: john@arbash-meinel.com-20060807212625-80d116ae82323e5c
Updated bench_bench tests to test exactly what we really want to test

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
20
22
 
21
23
 
29
31
 
30
32
    def test_02_make_kernel_like_tree(self):
31
33
        """Hardlinking a kernel-like working tree should be ~1s"""
32
 
        # Make sure we have populated the cache first
33
 
        self.make_kernel_like_tree(root='foo', hardlink_working=True)
 
34
        # make sure kernel_like_tree is cached
 
35
        self._cache_kernel_like_tree()
34
36
        self.time(self.make_kernel_like_tree, root='bar',
35
37
                  hardlink_working=True)
36
38
 
37
39
    def test_03_make_kernel_like_added_tree(self):
38
40
        """Time the first creation of a kernel like added tree"""
39
 
        # This may not be an accurate test, in the case that the cached entry
40
 
        # has already been created
41
 
        self.time(self.make_kernel_like_added_tree, root='foo')
 
41
        orig_cache = Benchmark.CACHE_ROOT
 
42
        try:
 
43
            # Change to a local cache directory so we know this
 
44
            # really creates the files
 
45
            Benchmark.CACHE_ROOT = osutils.abspath('cache')
 
46
            self.time(self.make_kernel_like_added_tree, root='foo')
 
47
        finally:
 
48
            Benchmark.CACHE_ROOT = orig_cache
42
49
 
43
50
    def test_04_make_kernel_like_added_tree(self):
44
51
        """Time the second creation of a kernel like added tree 
45
52
        (this should be a clone)
46
53
        """
47
 
        # Call make_kernel_like_added_tree to make sure it is cached
48
 
        self.make_kernel_like_added_tree(root='foo')
 
54
        # make sure kernel_like_added_tree is cached
 
55
        self._cache_kernel_like_added_tree()
49
56
        self.time(self.make_kernel_like_added_tree, root='bar')
50
57
 
51
58
    def test_05_make_kernel_like_committed_tree(self):
52
59
        """Time the first creation of a committed kernel like tree"""
53
 
        # This may not be an accurate test, in the case that the cached entry
54
 
        # has already been created
55
 
        self.time(self.make_kernel_like_committed_tree, root='foo')
 
60
        orig_cache = Benchmark.CACHE_ROOT
 
61
        try:
 
62
            # Change to a local cache directory so we know this
 
63
            # really creates the files
 
64
            Benchmark.CACHE_ROOT = osutils.abspath('cache')
 
65
            self.time(self.make_kernel_like_committed_tree, root='foo')
 
66
        finally:
 
67
            Benchmark.CACHE_ROOT = orig_cache
56
68
 
57
69
    def test_06_make_kernel_like_committed_tree(self):
58
70
        """Time the second creation of a committed kernel like tree 
59
71
        (this should be a clone)
60
72
        """
61
73
        # Call make_kernel_like_committed_tree to make sure it is cached
62
 
        # we just throw it away, so hardlink the first bzr directory
63
 
        self.make_kernel_like_committed_tree(root='foo', hardlink_bzr=True)
 
74
        self._cache_kernel_like_committed_tree()
64
75
        self.time(self.make_kernel_like_committed_tree, root='bar')
65
76
 
66
77
    def test_07_make_kernel_like_committed_tree_hardlink(self):
67
78
        """Time the creation of a committed kernel like tree 
68
79
        (this should also hardlink the .bzr/ directory)
69
80
        """
70
 
        # Call make_kernel_like_committed_tree to make sure it is cached
71
 
        self.make_kernel_like_committed_tree(root='foo', hardlink_bzr=True)
 
81
        # make sure kernel_like_committed_tree is cached
 
82
        self._cache_kernel_like_committed_tree()
72
83
        self.time(self.make_kernel_like_committed_tree, root='bar',
73
84
                    hardlink_bzr=True)
74
85