/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_startup.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-02-04 17:41:12 UTC
  • mto: (2323.7.1 redirection)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: v.ladeuil+lp@free.fr-20070204174112-iv6gxzinnjddlaxj
Add tests for redirection. Preserve transport decorations.

* bzrlib/tests/test_http.py:
(TestRedirections): new tests.

* bzrlib/tests/HttpServer.py:
(HttpServer): Make server host and port public once the socket
have been established.

* bzrlib/tests/HTTPTestUtil.py:
(RedirectRequestHandler, HTTPServerRedirecting): New http test
server for redirections. Only a whole host can be redirected, so
far.

* bzrlib/errors.py:
(RedirectRequested.__init__): Add a 'qual_proto' oso that
transport decorations can be transmitted to redirected transport.
(RedirectRequested._requalify_url,
RedirectRequested.get_source_url,
RedirectRequested.get_target_url): New methods providing fully
decorated urls.

* bzrlib/bzrdir.py:
(BzrDir.open_from_transport): The redirection should preserve
transport decorations.
(BzrDirMetaFormat1): To be able to specialize bzr branches from
foreign branches, we need to register BzrDirMetaFormat1 as the
default control format (instead of BzrDirMetaFormat which is
abstract and can still be used by foreign branches).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 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 as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Benchmarks of bzr startup time, for some simple operations."""
 
18
 
 
19
 
 
20
from bzrlib.benchmarks import Benchmark
 
21
 
 
22
 
 
23
class StartupBenchmark(Benchmark):
 
24
 
 
25
    def make_simple_tree(self):
 
26
        """A small, simple tree. No caching needed"""
 
27
        tree = self.make_branch_and_tree('.')
 
28
        self.build_tree(['a', 'b/', 'b/c'])
 
29
        tree.add(['a', 'b', 'b/c'])
 
30
        return tree
 
31
 
 
32
    def make_simple_committed_tree(self):
 
33
        tree = self.make_simple_tree()
 
34
        tree.commit('simple commit')
 
35
        return tree
 
36
 
 
37
    def test___version(self):
 
38
        """Test the startup overhead of plain bzr --version"""
 
39
        self.time(self.run_bzr_subprocess, '--version')
 
40
 
 
41
    def test_branch(self):
 
42
        """Test the time to branch this into other"""
 
43
        tree = self.make_simple_committed_tree()
 
44
        self.time(self.run_bzr_subprocess, 'branch', '.', 'other')
 
45
 
 
46
    def test_commit(self):
 
47
        """Test execution of simple commit"""
 
48
        tree = self.make_simple_tree()
 
49
        self.time(self.run_bzr_subprocess, 'commit', '-m', 'init simple tree')
 
50
 
 
51
    def test_diff(self):
 
52
        """Test simple diff time"""
 
53
        tree = self.make_simple_committed_tree()
 
54
        self.time(self.run_bzr_subprocess, 'diff')
 
55
 
 
56
    def test_help(self):
 
57
        """Test the startup overhead of plain bzr help"""
 
58
        self.time(self.run_bzr_subprocess, 'help')
 
59
 
 
60
    def test_help_commands(self):
 
61
        """startup time for bzr help commands, which has to load more"""
 
62
        self.time(self.run_bzr_subprocess, 'help', 'commands')
 
63
 
 
64
    def test_log(self):
 
65
        """Test simple log time"""
 
66
        tree = self.make_simple_committed_tree()
 
67
        self.time(self.run_bzr_subprocess, 'log')
 
68
 
 
69
    def test_missing(self):
 
70
        """Test simple missing time"""
 
71
        tree = self.make_simple_committed_tree()
 
72
        other = tree.bzrdir.sprout('other')
 
73
        self.time(self.run_bzr_subprocess, 'missing', working_dir='other')
 
74
 
 
75
    def test_pull(self):
 
76
        """Test simple pull time"""
 
77
        tree = self.make_simple_committed_tree()
 
78
        other = tree.bzrdir.sprout('other')
 
79
        # There should be nothing to pull, and this should be determined
 
80
        # quickly
 
81
        self.time(self.run_bzr_subprocess, 'pull', working_dir='other')
 
82
 
 
83
    def test_rocks(self):
 
84
        """Test the startup overhead by running a do-nothing command"""
 
85
        self.time(self.run_bzr_subprocess, 'rocks')
 
86
 
 
87
    def test_status(self):
 
88
        """Test simple status time"""
 
89
        tree = self.make_simple_committed_tree()
 
90
        self.time(self.run_bzr_subprocess, 'status')