~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-06-23 15:50:16 UTC
  • mfrom: (1756.2.23 log.perf)
  • Revision ID: pqm@pqm.ubuntu.com-20060623155016-476962c2dd4938a2
Optimize performance of log --short and log --line

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        self.build_tree(files)
54
54
 
55
55
    def make_many_commit_tree(self, directory_name='.'):
56
 
        """Create a tree with an egregious number of commits.
 
56
        """Create a tree with many commits.
57
57
        
58
58
        No files change are included.
59
59
        """
74
74
                tree.unlock()
75
75
        return tree
76
76
 
 
77
    def make_heavily_merged_tree(self, directory_name='.'):
 
78
        """Create a tree in which almost every commit is a merge.
 
79
       
 
80
        No files change are included.  This produces two trees, 
 
81
        one of which is returned.  Except for the first commit, every
 
82
        commit in its revision-history is a merge another commit in the other
 
83
        tree.
 
84
        """
 
85
        tree = BzrDir.create_standalone_workingtree(directory_name)
 
86
        tree.lock_write()
 
87
        try:
 
88
            tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
 
89
            tree2.lock_write()
 
90
            try:
 
91
                for i in xrange(250):
 
92
                    revision_id = tree.commit('no-changes commit %d-a' % i)
 
93
                    tree2.branch.fetch(tree.branch, revision_id)
 
94
                    tree2.set_pending_merges([revision_id])
 
95
                    revision_id = tree2.commit('no-changes commit %d-b' % i)
 
96
                    tree.branch.fetch(tree2.branch, revision_id)
 
97
                    tree.set_pending_merges([revision_id])
 
98
                tree.set_pending_merges([])
 
99
            finally:
 
100
                tree.unlock()
 
101
        finally:
 
102
            tree2.unlock()
 
103
        return tree
 
104
 
77
105
 
78
106
def test_suite():
79
107
    """Build and return a TestSuite which contains benchmark tests only."""