~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_bench.py

  • Committer: Ian Clatworthy
  • Date: 2009-01-19 02:24:15 UTC
  • mto: This revision was merged to the branch mainline in revision 3944.
  • Revision ID: ian.clatworthy@canonical.com-20090119022415-mo0mcfeiexfktgwt
apply jam's log --short fix (Ian Clatworthy)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
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.
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
6
7
#
7
8
# This program is distributed in the hope that it will be useful,
8
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
16
 
16
17
"""Tests for bzr benchmark utilities performance."""
17
18
 
18
 
 
 
19
from bzrlib import (
 
20
    osutils,
 
21
    )
19
22
from bzrlib.benchmarks import Benchmark
 
23
from bzrlib.benchmarks.tree_creator.kernel_like import (
 
24
    KernelLikeTreeCreator,
 
25
    KernelLikeAddedTreeCreator,
 
26
    KernelLikeCommittedTreeCreator,
 
27
    )
 
28
from bzrlib.tests import TestSkipped
20
29
 
21
30
 
22
31
class MakeKernelLikeTreeBenchmark(Benchmark):
 
32
    """Benchmark creating benchmark trees."""
23
33
 
24
34
    def test_make_kernel_like_tree(self):
25
35
        """Making a kernel sized tree should be ~ 5seconds on modern disk.""" 
26
36
        # on roberts machine: this originally took:  7372ms/ 7479ms
27
37
        # with the LocalTransport._abspath call:     3730ms/ 3778ms
 
38
        # with AtomicFile tuning:                    2888ms/ 2926ms
 
39
        # switching to transport.append_bytes:       1468ms/ 2849ms
28
40
        self.time(self.make_kernel_like_tree)
 
41
 
 
42
    def test_02_make_kernel_like_tree(self):
 
43
        """Hardlinking a kernel-like working tree should be ~1s"""
 
44
        # make sure kernel_like_tree is cached
 
45
        creator = KernelLikeTreeCreator(self, link_working=True)
 
46
        if not creator.is_caching_enabled():
 
47
            raise TestSkipped('caching is disabled')
 
48
        creator.ensure_cached()
 
49
        self.time(creator.create, root='bar')
 
50
 
 
51
    def test_03_make_kernel_like_added_tree(self):
 
52
        """Time the first creation of a kernel like added tree"""
 
53
        creator = KernelLikeAddedTreeCreator(self)
 
54
        creator.disable_cache()
 
55
        self.time(creator.create, root='foo')
 
56
 
 
57
    def test_04_make_kernel_like_added_tree(self):
 
58
        """Time the second creation of a kernel like added tree 
 
59
        (this should be a clone)
 
60
        """
 
61
        # make sure kernel_like_added_tree is cached
 
62
        creator = KernelLikeAddedTreeCreator(self, link_working=True)
 
63
        if not creator.is_caching_enabled():
 
64
            # Caching is disabled, this test is meaningless
 
65
            raise TestSkipped('caching is disabled')
 
66
        creator.ensure_cached()
 
67
        self.time(creator.create, root='bar')
 
68
 
 
69
    def test_05_make_kernel_like_committed_tree(self):
 
70
        """Time the first creation of a committed kernel like tree"""
 
71
        creator = KernelLikeCommittedTreeCreator(self)
 
72
        creator.disable_cache()
 
73
        self.time(creator.create, root='foo')
 
74
 
 
75
    def test_06_make_kernel_like_committed_tree(self):
 
76
        """Time the second creation of a committed kernel like tree 
 
77
        (this should be a clone)
 
78
        """
 
79
        creator = KernelLikeCommittedTreeCreator(self,
 
80
                                                 link_working=True,
 
81
                                                 link_bzr=False)
 
82
        if not creator.is_caching_enabled():
 
83
            # Caching is disabled, this test is meaningless
 
84
            raise TestSkipped('caching is disabled')
 
85
        creator.ensure_cached()
 
86
        self.time(creator.create, root='bar')
 
87
 
 
88
    def test_07_make_kernel_like_committed_tree_hardlink(self):
 
89
        """Time the creation of a committed kernel like tree 
 
90
        (this should also hardlink the .bzr/ directory)
 
91
        """
 
92
        creator = KernelLikeCommittedTreeCreator(self,
 
93
                                                 link_working=True,
 
94
                                                 link_bzr=True)
 
95
        if not creator.is_caching_enabled():
 
96
            # Caching is disabled, this test is meaningless
 
97
            raise TestSkipped('caching is disabled')
 
98
        creator.ensure_cached()
 
99
        self.time(creator.create, root='bar')
 
100
 
 
101