/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2063.1.1 by John Arbash Meinel
spin off startup benchmarks to their own branch
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
"""Benchmarks of bzr startup time, for some simple operations."""
17
18
19
from bzrlib.benchmarks import Benchmark
20
21
22
class StartupBenchmark(Benchmark):
23
24
    def make_simple_tree(self):
25
        """A small, simple tree. No caching needed"""
26
        tree = self.make_branch_and_tree('.')
27
        self.build_tree(['a', 'b/', 'b/c'])
28
        tree.add(['a', 'b', 'b/c'])
29
        return tree
30
31
    def make_simple_committed_tree(self):
32
        tree = self.make_simple_tree()
33
        tree.commit('simple commit')
34
        return tree
35
36
    def test___version(self):
37
        """Test the startup overhead of plain bzr --version"""
38
        self.time(self.run_bzr_subprocess, '--version')
39
40
    def test_branch(self):
41
        """Test the time to branch this into other"""
42
        tree = self.make_simple_committed_tree()
43
        self.time(self.run_bzr_subprocess, 'branch', '.', 'other')
44
45
    def test_commit(self):
46
        """Test execution of simple commit"""
47
        tree = self.make_simple_tree()
48
        self.time(self.run_bzr_subprocess, 'commit', '-m', 'init simple tree')
49
50
    def test_diff(self):
51
        """Test simple diff time"""
52
        tree = self.make_simple_committed_tree()
53
        self.time(self.run_bzr_subprocess, 'diff')
54
55
    def test_help(self):
56
        """Test the startup overhead of plain bzr help"""
57
        self.time(self.run_bzr_subprocess, 'help')
58
59
    def test_help_commands(self):
60
        """startup time for bzr help commands, which has to load more"""
61
        self.time(self.run_bzr_subprocess, 'help', 'commands')
62
63
    def test_log(self):
64
        """Test simple log time"""
65
        tree = self.make_simple_committed_tree()
66
        self.time(self.run_bzr_subprocess, 'log')
67
68
    def test_missing(self):
69
        """Test simple missing time"""
70
        tree = self.make_simple_committed_tree()
71
        other = tree.bzrdir.sprout('other')
72
        self.time(self.run_bzr_subprocess, 'missing', working_dir='other')
73
74
    def test_pull(self):
75
        """Test simple pull time"""
76
        tree = self.make_simple_committed_tree()
77
        other = tree.bzrdir.sprout('other')
78
        # There should be nothing to pull, and this should be determined
79
        # quickly
80
        self.time(self.run_bzr_subprocess, 'pull', working_dir='other')
81
82
    def test_rocks(self):
83
        """Test the startup overhead by running a do-nothing command"""
84
        self.time(self.run_bzr_subprocess, 'rocks')
85
86
    def test_status(self):
87
        """Test simple status time"""
88
        tree = self.make_simple_committed_tree()
89
        self.time(self.run_bzr_subprocess, 'status')