bench_commit.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_commit.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

"""Benchmarks of bzr commit."""

import os

from bzrlib.benchmarks import Benchmark
from bzrlib.transport.memory import MemoryServer
from bzrlib.transport import get_transport


class CommitBenchmark(Benchmark):
    """Benchmarks for ``bzr commit``"""

    def test_commit_kernel_like_tree(self):
        """Commit of a fresh import of a clean kernel sized tree."""
        # uncomment this to run the benchmark with the repository in memory
        # not disk
        # self.transport_server = MemoryServer
        # self.make_kernel_like_tree(self.get_url())
        tree = self.make_kernel_like_added_tree()
        self.time(self.run_bzr, ['commit', '-m', 'first post'])

    def test_partial_commit_kernel_like_tree(self):
        """Commit of 1/8th of a fresh import of a clean kernel sized tree."""
        tree = self.make_kernel_like_added_tree()
        self.time(self.run_bzr, ['commit', '-m', 'first post', '1'])

    def test_no_op_commit_in_kernel_like_tree(self):
        """Run commit --unchanged in a kernel sized tree"""
        tree = self.make_kernel_like_committed_tree()
        self.time(self.run_bzr, ['commit', '-m', 'no changes', '--unchanged'])

    def test_commit_one_in_kernel_like_tree(self):
        """Time committing a single change, when not directly specified"""
        tree = self.make_kernel_like_committed_tree()

        # working-tree is hardlinked, so replace a file and commit the change
        os.remove('4/4/4/4')
        open('4/4/4/4', 'wb').write('new contents\n')
        self.time(self.run_bzr, ['commit', '-m', 'second'])

    def test_partial_commit_one_in_kernel_like_tree(self):
        """Time committing a single change when it is directly specified"""
        tree = self.make_kernel_like_committed_tree()

        # working-tree is hardlinked, so replace a file and commit the change
        os.remove('4/4/4/4')
        open('4/4/4/4', 'wb').write('new contents\n')
        self.time(self.run_bzr, ['commit', '-m', 'second', '4/4/4/4'])

    def make_simple_tree(self):
        """A small, simple tree. No caching needed"""
        tree = self.make_branch_and_tree('.')
        self.build_tree(['a', 'b/', 'b/c'])
        tree.add(['a', 'b', 'b/c'])
        return tree

    def test_cmd_commit(self):
        """Test execution of simple commit"""
        tree = self.make_simple_tree()
        self.time(self.run_bzr, ['commit', '-m', 'init simple tree'])

    def test_cmd_commit_subprocess(self):
        """Text startup and execution of a simple commit."""
        tree = self.make_simple_tree()
        self.time(self.run_bzr_subprocess, 'commit', '-m', 'init simple tree')
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.