~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/bench_sftp.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-14 16:16:53 UTC
  • mto: (1946.2.6 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1919.
  • Revision ID: john@arbash-meinel.com-20060814161653-54cdcdadcd4e9003
Remove bogus entry from BRANCH.TODO

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
 
"""Tests for bzr performance over SFTP"""
17
 
 
18
 
import os
19
 
 
20
 
from bzrlib import (
21
 
    bzrdir,
22
 
    )
23
 
from bzrlib.benchmarks import Benchmark
24
 
from bzrlib.tests import test_sftp_transport
25
 
 
26
 
try:
27
 
    import paramiko
28
 
    paramiko_loaded = True
29
 
except ImportError:
30
 
    paramiko_loaded = False
31
 
 
32
 
 
33
 
class SFTPBenchmark(Benchmark):
34
 
    """Benchmark branch, push and pull across a local sftp connection."""
35
 
 
36
 
    def setUp(self):
37
 
        super(SFTPBenchmark, self).setUp()
38
 
        if not paramiko_loaded:
39
 
            raise TestSkipped('you must have paramiko to run this test')
40
 
        test_sftp_transport.set_test_transport_to_sftp(self)
41
 
         
42
 
    def test_branch(self):
43
 
        os.mkdir("a")
44
 
        tree, files = self.create_with_commits(100, 100, "a")
45
 
        self.time(bzrdir.BzrDir.open(self.get_url('a')).sprout, "b")
46
 
 
47
 
    def create_commit_and_pull(self, num_pull_revisions):
48
 
        os.mkdir("a")
49
 
        tree, files = self.create_with_commits(100, 100, "a")
50
 
        rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
51
 
        b2 = tree.bzrdir.sprout("b") # branch
52
 
        # change a few files and commit
53
 
        self.commit_some_revisions(tree, files, num_pull_revisions, 20)
54
 
        self.time(b2.open_branch().pull, rbzrdir.open_branch())
55
 
 
56
 
    def test_pull_1(self):
57
 
        self.create_commit_and_pull(1)
58
 
        
59
 
    def test_pull_10(self):
60
 
        self.create_commit_and_pull(10)
61
 
 
62
 
    def test_pull_100(self):
63
 
        self.create_commit_and_pull(100)
64
 
 
65
 
    def create_commit_and_push(self, num_push_revisions):
66
 
        os.mkdir("a")
67
 
        tree, files = self.create_with_commits(100, 100, "a")
68
 
        rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
69
 
        b2 = tree.bzrdir.sprout("b") # branch
70
 
        wtree = b2.open_workingtree()
71
 
        # change a few files and commit
72
 
        self.commit_some_revisions(
73
 
            wtree, ["b/%i" for i in range(100)],
74
 
            num_commits=num_push_revisions,
75
 
            changes_per_commit=20)
76
 
        self.time(rbzrdir.open_branch().pull, wtree.branch)
77
 
 
78
 
    def test_initial_push(self):
79
 
        os.mkdir('a')
80
 
        tree, files = self.create_with_commits(100, 100, "a")
81
 
        self.time(tree.bzrdir.clone, self.get_url('b'),
82
 
                  revision_id=tree.last_revision())
83
 
 
84
 
    def test_push_1(self):
85
 
        self.create_commit_and_push(1)
86
 
 
87
 
    def test_push_10(self):
88
 
        self.create_commit_and_push(10)
89
 
 
90
 
    def test_push_100(self):
91
 
        self.create_commit_and_push(100)
92
 
 
93
 
 
94
 
class SFTPSlowSocketBenchmark(SFTPBenchmark):
95
 
    def setUp(self):
96
 
        super(SFTPSlowSocketBenchmark, self).setUp()
97
 
        self.get_server().add_latency = 0.03
98