1
# Copyright (C) 2006 by Canonical Ltd
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.
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.
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
16
"""Benchmarks of bzr startup time, for some simple operations."""
19
from bzrlib.benchmarks import Benchmark
22
class StartupBenchmark(Benchmark):
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'])
31
def make_simple_committed_tree(self):
32
tree = self.make_simple_tree()
33
tree.commit('simple commit')
36
def test___version(self):
37
"""Test the startup overhead of plain bzr --version"""
38
self.time(self.run_bzr_subprocess, '--version')
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')
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')
51
"""Test simple diff time"""
52
tree = self.make_simple_committed_tree()
53
self.time(self.run_bzr_subprocess, 'diff')
56
"""Test the startup overhead of plain bzr help"""
57
self.time(self.run_bzr_subprocess, 'help')
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')
64
"""Test simple log time"""
65
tree = self.make_simple_committed_tree()
66
self.time(self.run_bzr_subprocess, 'log')
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')
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
80
self.time(self.run_bzr_subprocess, 'pull', working_dir='other')
83
"""Test the startup overhead by running a do-nothing command"""
84
self.time(self.run_bzr_subprocess, 'rocks')
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')