/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
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
22
from bzrlib.tests import TestSkipped
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
23
24
25
class MakeKernelLikeTreeBenchmark(Benchmark):
26
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
27
    def test_make_kernel_like_tree(self):
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
28
        """Making a kernel sized tree should be ~ 5seconds on modern disk.""" 
29
        # on roberts machine: this originally took:  7372ms/ 7479ms
1755.1.2 by Robert Collins
(robertc, ab)Merge some commit and fetch tuning steps.
30
        # 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.
31
        # with AtomicFile tuning:                    2888ms/ 2926ms
32
        # switching to transport.append:             1468ms/ 2849ms
1755.2.1 by Robert Collins
Add a benchmark for make_kernel_like_tree.
33
        self.time(self.make_kernel_like_tree)
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
34
35
    def test_02_make_kernel_like_tree(self):
36
        """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
37
        # make sure kernel_like_tree is cached
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
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)
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
45
        self.time(self.make_kernel_like_tree, root='bar',
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
46
                  link_working=True)
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
47
48
    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.
49
        """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
50
        orig_cache = Benchmark.CACHE_ROOT
51
        try:
52
            # Change to a local cache directory so we know this
53
            # really creates the files
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
54
            Benchmark.CACHE_ROOT = None
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
55
            self.time(self.make_kernel_like_added_tree, root='foo')
56
        finally:
57
            Benchmark.CACHE_ROOT = orig_cache
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
58
59
    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.
60
        """Time the second creation of a kernel like added tree 
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
61
        (this should be a clone)
62
        """
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
63
        # make sure kernel_like_added_tree is cached
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
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')
1908.2.2 by John Arbash Meinel
Allow caching basic kernel-like trees
71
        self.time(self.make_kernel_like_added_tree, root='bar')
72
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
73
    def test_05_make_kernel_like_committed_tree(self):
74
        """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
75
        orig_cache = Benchmark.CACHE_ROOT
76
        try:
77
            # Change to a local cache directory so we know this
78
            # really creates the files
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
79
            Benchmark.CACHE_ROOT = None
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
80
            self.time(self.make_kernel_like_committed_tree, root='foo')
81
        finally:
82
            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.
83
84
    def test_06_make_kernel_like_committed_tree(self):
85
        """Time the second creation of a committed kernel like tree 
86
        (this should be a clone)
87
        """
88
        # Call make_kernel_like_committed_tree to make sure it is cached
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
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')
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
94
        self.time(self.make_kernel_like_committed_tree, root='bar')
95
96
    def test_07_make_kernel_like_committed_tree_hardlink(self):
97
        """Time the creation of a committed kernel like tree 
98
        (this should also hardlink the .bzr/ directory)
99
        """
1908.2.5 by John Arbash Meinel
Updated bench_bench tests to test exactly what we really want to test
100
        # make sure kernel_like_committed_tree is cached
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
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')
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
106
        self.time(self.make_kernel_like_committed_tree, root='bar',
1908.2.11 by John Arbash Meinel
Change caching logic. Don't cache at all without --cache-dir being supplied
107
                    link_bzr=True)
1908.2.3 by John Arbash Meinel
Support caching a committed kernel-like tree, and mark hardlinked trees as readonly.
108
109