3
from bzrlib.benchmarks import Benchmark
4
from bzrlib import bzrdir
5
from bzrlib.tests import test_sftp_transport
6
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
7
import bzrlib.transport.http
8
from bzrlib.workingtree import WorkingTree
12
paramiko_loaded = True
14
paramiko_loaded = False
17
class SFTPBenchmark(Benchmark):
18
"""Benchmark branch, push and pull across a local sftp connection."""
21
super(SFTPBenchmark, self).setUp()
22
if not paramiko_loaded:
23
raise TestSkipped('you must have paramiko to run this test')
24
test_sftp_transport.set_test_transport_to_sftp(self)
26
def test_branch(self):
28
tree, files = self.create_with_commits(100, 100, "a")
29
self.time(bzrdir.BzrDir.open(self.get_url('a')).sprout, "b")
31
def test_pull_1(self):
33
tree, files = self.create_with_commits(100, 100, "a")
34
rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
35
b2 = tree.bzrdir.sprout("b") # branch
36
# change a few files and commit
37
self.commit_some_revisions(tree, files, 1, 20)
38
self.time(b2.open_branch().pull, rbzrdir.open_branch())
40
def test_pull_100(self):
42
tree, files = self.create_with_commits(100, 100, "a")
43
rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
44
b2 = tree.bzrdir.sprout("b") # branch
45
# change a few files and commit
46
self.commit_some_revisions(tree, files, 100, 20)
47
self.time(b2.open_branch().pull, rbzrdir.open_branch())
49
def create_commit_and_push(self, num_push_revisions):
51
tree, files = self.create_with_commits(100, 100, "a")
52
rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
53
b2 = rbzrdir.sprout("b") # branch
54
wtree = b2.open_workingtree()
55
# change a few files and commit
56
self.commit_some_revisions(
57
wtree, ["b/%i" for i in range(100)],
58
num_commits=num_push_revisions,
59
changes_per_commit=20)
60
self.time(rbzrdir.open_branch().pull, wtree.branch)
62
def test_push_1(self):
63
self.create_commit_and_push(1)
65
def test_push_10(self):
66
self.create_commit_and_push(10)
68
def test_push_100(self):
69
self.create_commit_and_push(100)
72
class SFTPSlowSocketBenchmark(SFTPBenchmark):
74
super(SFTPSlowSocketBenchmark, self).setUp()
75
self.get_server().add_latency = 0.03