bench_sftp.py :  » Development » Bazaar » bzr-2.2b3 » bzrlib » benchmarks » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Development » Bazaar 
Bazaar » bzr 2.2b3 » bzrlib » benchmarks » bench_sftp.py
# Copyright (C) 2006 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

"""Tests for bzr performance over SFTP"""

import os

from bzrlib import (
    bzrdir,
    )
from bzrlib.benchmarks import Benchmark
from bzrlib.tests import test_sftp_transport,TestSkipped

try:
    import paramiko
    paramiko_loaded = True
except ImportError:
    paramiko_loaded = False


class SFTPBenchmark(Benchmark):
    """Benchmark branch, push and pull across a local sftp connection."""

    def setUp(self):
        super(SFTPBenchmark, self).setUp()
        if not paramiko_loaded:
            raise TestSkipped('you must have paramiko to run this test')
        test_sftp_transport.set_test_transport_to_sftp(self)

    def test_branch(self):
        os.mkdir("a")
        tree, files = self.create_with_commits(100, 100, "a")
        self.time(bzrdir.BzrDir.open(self.get_url('a')).sprout, "b")

    def create_commit_and_pull(self, num_pull_revisions):
        os.mkdir("a")
        tree, files = self.create_with_commits(100, 100, "a")
        rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
        b2 = tree.bzrdir.sprout("b") # branch
        # change a few files and commit
        self.commit_some_revisions(tree, files, num_pull_revisions, 20)
        self.time(b2.open_branch().pull, rbzrdir.open_branch())

    def test_pull_1(self):
        self.create_commit_and_pull(1)

    def test_pull_10(self):
        self.create_commit_and_pull(10)

    def test_pull_100(self):
        self.create_commit_and_pull(100)

    def create_commit_and_push(self, num_push_revisions):
        os.mkdir("a")
        tree, files = self.create_with_commits(100, 100, "a")
        rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
        b2 = tree.bzrdir.sprout("b") # branch
        wtree = b2.open_workingtree()
        # change a few files and commit
        self.commit_some_revisions(
            wtree, ["b/%i" for i in range(100)],
            num_commits=num_push_revisions,
            changes_per_commit=20)
        self.time(rbzrdir.open_branch().pull, wtree.branch)

    def test_initial_push(self):
        os.mkdir('a')
        tree, files = self.create_with_commits(100, 100, "a")
        self.time(tree.bzrdir.clone, self.get_url('b'),
                  revision_id=tree.last_revision())

    def test_push_1(self):
        self.create_commit_and_push(1)

    def test_push_10(self):
        self.create_commit_and_push(10)

    def test_push_100(self):
        self.create_commit_and_push(100)


class SFTPSlowSocketBenchmark(SFTPBenchmark):
    """Benchmarks of SFTP performance with a 30ms delay per roundtrip."""

    def setUp(self):
        super(SFTPSlowSocketBenchmark, self).setUp()
        self.get_server().add_latency = 0.03

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.