/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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
    )
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
21
from bzrlib.benchmarks import Benchmark
22
23
24
class MakeKernelLikeTreeBenchmark(Benchmark):
25
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
26
    def test_01_make_kernel_like_tree(self):
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
27
        """Making a kernel sized tree should be ~ 5seconds on modern disk.""" 
28
        # on roberts machine: this originally took:  7372ms/ 7479ms
1755.1.2 by Robert Collins
(robertc, ab)Merge some commit and fetch tuning steps.
29
        # 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.
30
        # with AtomicFile tuning:                    2888ms/ 2926ms
31
        # switching to transport.append:             1468ms/ 2849ms
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
32
        self.time(self.make_kernel_like_tree)
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
33
34
    def test_02_make_kernel_like_tree(self):
35
        """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
36
        # make sure kernel_like_tree is cached
37
        self._cache_kernel_like_tree()
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
38
        self.time(self.make_kernel_like_tree, root='bar',
39
                  hardlink_working=True)
40
41
    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.
42
        """Time the first creation of a kernel like added tree"""
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
43
        orig_cache = Benchmark.CACHE_ROOT
44
        try:
45
            # Change to a local cache directory so we know this
46
            # really creates the files
47
            Benchmark.CACHE_ROOT = osutils.abspath('cache')
48
            self.time(self.make_kernel_like_added_tree, root='foo')
49
        finally:
50
            Benchmark.CACHE_ROOT = orig_cache
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
51
52
    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.
53
        """Time the second creation of a kernel like added tree 
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
54
        (this should be a clone)
55
        """
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
56
        # make sure kernel_like_added_tree is cached
57
        self._cache_kernel_like_added_tree()
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
58
        self.time(self.make_kernel_like_added_tree, root='bar')
59
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
60
    def test_05_make_kernel_like_committed_tree(self):
61
        """Time the first creation of a committed kernel like tree"""
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
62
        orig_cache = Benchmark.CACHE_ROOT
63
        try:
64
            # Change to a local cache directory so we know this
65
            # really creates the files
66
            Benchmark.CACHE_ROOT = osutils.abspath('cache')
67
            self.time(self.make_kernel_like_committed_tree, root='foo')
68
        finally:
69
            Benchmark.CACHE_ROOT = orig_cache
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
70
71
    def test_06_make_kernel_like_committed_tree(self):
72
        """Time the second creation of a committed kernel like tree 
73
        (this should be a clone)
74
        """
75
        # Call make_kernel_like_committed_tree to make sure it is cached
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
76
        self._cache_kernel_like_committed_tree()
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
77
        self.time(self.make_kernel_like_committed_tree, root='bar')
78
79
    def test_07_make_kernel_like_committed_tree_hardlink(self):
80
        """Time the creation of a committed kernel like tree 
81
        (this should also hardlink the .bzr/ directory)
82
        """
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
83
        # make sure kernel_like_committed_tree is cached
84
        self._cache_kernel_like_committed_tree()
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
85
        self.time(self.make_kernel_like_committed_tree, root='bar',
86
                    hardlink_bzr=True)
87
88