/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: 2006-10-12 14:29:32 UTC
  • mto: (2145.1.1 keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: v.ladeuil+lp@free.fr-20061012142932-7221fe16d2b48fa3
Shuffle http related test code. Hopefully it ends up at the right place :)

* bzrlib/tests/HttpServer.py: 
New file. bzrlib.tests.ChrootedTestCase use HttpServer. So the
class can't be defined in bzrlib.tests.HTTPUtils because it
creates a circular dependency (bzrlib.tests.HTTPUtils needs to
import bzrlib.tests).

* bzrlib/transport/http/_urllib.py: 
Transfer test server definition to bzrlib.tests.HttpServer. Clean
up imports.

* bzrlib/transport/http/_pycurl.py: 
Transfer test server definition to bzrlib.tests.HttpServer. Clean
up imports.

* bzrlib/transport/http/__init__.py: 
Transfer all test related code to either bzrlib.tests.HttpServer
and bzrlib.tests.HTTPUtils.
Fix all use of TransportNotPossible and InvalidURL by prefixing it
by 'errors.' (this seems to be the preferred way in the rest of
bzr).
Get rid of unused imports.

* bzrlib/tests/test_transport.py:
(ReadonlyDecoratorTransportTest.test_local_parameters,
FakeNFSDecoratorTests.test_http_parameters): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

* bzrlib/tests/test_sftp_transport.py:
(set_test_transport_to_sftp): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

* bzrlib/tests/test_selftest.py:
(TestTestCaseWithTransport.test_get_readonly_url_http): Use
HttpServer from bzrlib.tests.HttpServer instead of
bzrlib.transport.http.

* bzrlib/tests/test_repository.py: 
Does *not* use HttpServer.

* bzrlib/tests/test_http.py: 
Build on top of bzrlib.tests.HttpServer and bzrlib.tests.HTTPUtils
instead of bzrlib.transport.http.

* bzrlib/tests/test_bzrdir.py:
(ChrootedTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/branch_implementations/test_http.py:
(HTTPBranchTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/branch_implementations/test_branch.py:
(ChrootedTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/__init__.py:
(ChrootedTestCase.setUp): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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')