~bzr-pqm/bzr/bzr.dev

1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
1
# Copyright (C) 2006 by Canonical Ltd
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License version 2 as published by
5
# the Free Software Foundation.
6
#
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
# GNU General Public License for more details.
11
#
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
16
"""Tests for bzr benchmark utilities performance."""
17
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
18
from bzrlib import (
19
    osutils,
20
    )
1908.2.16 by John Arbash Meinel
Move all the new TreeCreator classes into separate files.
21
from bzrlib.benchmarks import Benchmark
22
from bzrlib.benchmarks.tree_creator.kernel_like import (
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
23
    KernelLikeTreeCreator,
24
    KernelLikeAddedTreeCreator,
25
    KernelLikeCommittedTreeCreator,
26
    )
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
27
from bzrlib.tests import TestSkipped
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
28
29
30
class MakeKernelLikeTreeBenchmark(Benchmark):
31
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
32
    def test_make_kernel_like_tree(self):
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
33
        """Making a kernel sized tree should be ~ 5seconds on modern disk.""" 
34
        # on roberts machine: this originally took:  7372ms/ 7479ms
1755.1.2 by Robert Collins
(robertc, ab)Merge some commit and fetch tuning steps.
35
        # with the LocalTransport._abspath call:     3730ms/ 3778ms
1755.3.1 by Robert Collins
Tune the time to build our kernel_like tree : make LocalTransport.put faster, AtomicFile faster, LocalTransport.append faster.
36
        # with AtomicFile tuning:                    2888ms/ 2926ms
1955.3.16 by John Arbash Meinel
Switch over to Transport.append_bytes or append_files
37
        # switching to transport.append_bytes:       1468ms/ 2849ms
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
38
        self.time(self.make_kernel_like_tree)
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
39
40
    def test_02_make_kernel_like_tree(self):
41
        """Hardlinking a kernel-like working tree should be ~1s"""
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
42
        # make sure kernel_like_tree is cached
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
43
        creator = KernelLikeTreeCreator(self, link_working=True)
44
        if not creator.is_caching_enabled():
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
45
            raise TestSkipped('caching is disabled')
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
46
        creator.ensure_cached()
47
        self.time(creator.create, root='bar')
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
48
49
    def test_03_make_kernel_like_added_tree(self):
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
50
        """Time the first creation of a kernel like added tree"""
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
51
        creator = KernelLikeAddedTreeCreator(self)
52
        creator.disable_cache()
53
        self.time(creator.create, root='foo')
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
54
55
    def test_04_make_kernel_like_added_tree(self):
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
56
        """Time the second creation of a kernel like added tree 
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
57
        (this should be a clone)
58
        """
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
59
        # make sure kernel_like_added_tree is cached
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
60
        creator = KernelLikeAddedTreeCreator(self, link_working=True)
61
        if not creator.is_caching_enabled():
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
62
            # Caching is disabled, this test is meaningless
63
            raise TestSkipped('caching is disabled')
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
64
        creator.ensure_cached()
65
        self.time(creator.create, root='bar')
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
66
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
67
    def test_05_make_kernel_like_committed_tree(self):
68
        """Time the first creation of a committed kernel like tree"""
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
69
        creator = KernelLikeCommittedTreeCreator(self)
70
        creator.disable_cache()
71
        self.time(creator.create, root='foo')
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
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
        """
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
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
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
82
            raise TestSkipped('caching is disabled')
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
83
        creator.ensure_cached()
84
        self.time(creator.create, root='bar')
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
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
        """
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
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
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
95
            raise TestSkipped('caching is disabled')
1908.2.14 by John Arbash Meinel
Hook the bench_bench.py tests up for the new classes
96
        creator.ensure_cached()
97
        self.time(creator.create, root='bar')
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
98
99