~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_bench.py

  • Committer: wang
  • Date: 2006-10-29 13:41:32 UTC
  • mto: (2104.4.1 wang_65714)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: wang@ubuntu-20061029134132-3d7f4216f20c4aef
Replace python's difflib by patiencediff because the worst case 
performance is cubic for difflib and people commiting large data 
files are often hurt by this. The worst case performance of patience is 
quadratic. Fix bug 65714.

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):
26
35
        # on roberts machine: this originally took:  7372ms/ 7479ms
27
36
        # with the LocalTransport._abspath call:     3730ms/ 3778ms
28
37
        # with AtomicFile tuning:                    2888ms/ 2926ms
29
 
        # switching to transport.append:             1468ms/ 2849ms
 
38
        # switching to transport.append_bytes:       1468ms/ 2849ms
30
39
        self.time(self.make_kernel_like_tree)
 
40
 
 
41
    def test_02_make_kernel_like_tree(self):
 
42
        """Hardlinking a kernel-like working tree should be ~1s"""
 
43
        # make sure kernel_like_tree is cached
 
44
        creator = KernelLikeTreeCreator(self, link_working=True)
 
45
        if not creator.is_caching_enabled():
 
46
            raise TestSkipped('caching is disabled')
 
47
        creator.ensure_cached()
 
48
        self.time(creator.create, root='bar')
 
49
 
 
50
    def test_03_make_kernel_like_added_tree(self):
 
51
        """Time the first creation of a kernel like added tree"""
 
52
        creator = KernelLikeAddedTreeCreator(self)
 
53
        creator.disable_cache()
 
54
        self.time(creator.create, root='foo')
 
55
 
 
56
    def test_04_make_kernel_like_added_tree(self):
 
57
        """Time the second creation of a kernel like added tree 
 
58
        (this should be a clone)
 
59
        """
 
60
        # make sure kernel_like_added_tree is cached
 
61
        creator = KernelLikeAddedTreeCreator(self, link_working=True)
 
62
        if not creator.is_caching_enabled():
 
63
            # Caching is disabled, this test is meaningless
 
64
            raise TestSkipped('caching is disabled')
 
65
        creator.ensure_cached()
 
66
        self.time(creator.create, root='bar')
 
67
 
 
68
    def test_05_make_kernel_like_committed_tree(self):
 
69
        """Time the first creation of a committed kernel like tree"""
 
70
        creator = KernelLikeCommittedTreeCreator(self)
 
71
        creator.disable_cache()
 
72
        self.time(creator.create, root='foo')
 
73
 
 
74
    def test_06_make_kernel_like_committed_tree(self):
 
75
        """Time the second creation of a committed kernel like tree 
 
76
        (this should be a clone)
 
77
        """
 
78
        creator = KernelLikeCommittedTreeCreator(self,
 
79
                                                 link_working=True,
 
80
                                                 link_bzr=False)
 
81
        if not creator.is_caching_enabled():
 
82
            # Caching is disabled, this test is meaningless
 
83
            raise TestSkipped('caching is disabled')
 
84
        creator.ensure_cached()
 
85
        self.time(creator.create, root='bar')
 
86
 
 
87
    def test_07_make_kernel_like_committed_tree_hardlink(self):
 
88
        """Time the creation of a committed kernel like tree 
 
89
        (this should also hardlink the .bzr/ directory)
 
90
        """
 
91
        creator = KernelLikeCommittedTreeCreator(self,
 
92
                                                 link_working=True,
 
93
                                                 link_bzr=True)
 
94
        if not creator.is_caching_enabled():
 
95
            # Caching is disabled, this test is meaningless
 
96
            raise TestSkipped('caching is disabled')
 
97
        creator.ensure_cached()
 
98
        self.time(creator.create, root='bar')
 
99
 
 
100