1707.2.2
by Robert Collins
Start on bench_add, an add benchtest. |
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 as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
||
18 |
"""Benchmark test suite for bzr."""
|
|
19 |
||
1711.2.78
by John Arbash Meinel
Cleanup the imports in bzrlib.benchmark |
20 |
from bzrlib import bzrdir, plugin |
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
21 |
from bzrlib.tests.TestUtil import TestLoader |
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
22 |
from bzrlib.tests.blackbox import ExternalBase |
23 |
||
1841.1.1
by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests |
24 |
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
25 |
class Benchmark(ExternalBase): |
26 |
||
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
27 |
def make_kernel_like_tree(self, url=None): |
28 |
"""Setup a temporary tree roughly like a kernel tree.
|
|
29 |
|
|
30 |
:param url: Creat the kernel like tree as a lightweight checkout
|
|
31 |
of a new branch created at url.
|
|
32 |
"""
|
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
33 |
# a kernel tree has ~10000 and 500 directory, with most files around
|
34 |
# 3-4 levels deep.
|
|
35 |
# we simulate this by three levels of dirs named 0-7, givin 512 dirs,
|
|
36 |
# and 20 files each.
|
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
37 |
if url is not None: |
1711.2.78
by John Arbash Meinel
Cleanup the imports in bzrlib.benchmark |
38 |
b = bzrdir.BzrDir.create_branch_convenience(url) |
39 |
d = bzrdir.BzrDir.create('.') |
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
40 |
bzrlib.branch.BranchReferenceFormat().initialize(d, b) |
41 |
d.create_workingtree() |
|
42 |
else: |
|
43 |
self.run_bzr('init') |
|
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
44 |
files = [] |
45 |
for outer in range(8): |
|
46 |
files.append("%s/" % outer) |
|
47 |
for middle in range(8): |
|
48 |
files.append("%s/%s/" % (outer, middle)) |
|
49 |
for inner in range(8): |
|
50 |
prefix = "%s/%s/%s/" % (outer, middle, inner) |
|
51 |
files.append(prefix) |
|
52 |
files.extend([prefix + str(foo) for foo in range(20)]) |
|
53 |
self.build_tree(files) |
|
1707.2.2
by Robert Collins
Start on bench_add, an add benchtest. |
54 |
|
1756.1.2
by Aaron Bentley
Show logs using get_revisions |
55 |
def make_many_commit_tree(self, directory_name='.'): |
1756.2.21
by Aaron Bentley
Clean up merge log benchmark |
56 |
"""Create a tree with many commits.
|
1756.1.2
by Aaron Bentley
Show logs using get_revisions |
57 |
|
58 |
No files change are included.
|
|
59 |
"""
|
|
1711.2.82
by John Arbash Meinel
minor fix from Jan Balster to get --benchmark to work again |
60 |
tree = bzrdir.BzrDir.create_standalone_workingtree(directory_name) |
1756.1.2
by Aaron Bentley
Show logs using get_revisions |
61 |
tree.lock_write() |
62 |
tree.branch.lock_write() |
|
63 |
tree.branch.repository.lock_write() |
|
64 |
try: |
|
65 |
for i in xrange(1000): |
|
66 |
tree.commit('no-changes commit %d' % i) |
|
67 |
finally: |
|
68 |
try: |
|
69 |
try: |
|
70 |
tree.branch.repository.unlock() |
|
71 |
finally: |
|
72 |
tree.branch.unlock() |
|
73 |
finally: |
|
74 |
tree.unlock() |
|
75 |
return tree |
|
76 |
||
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
77 |
def make_heavily_merged_tree(self, directory_name='.'): |
1756.2.21
by Aaron Bentley
Clean up merge log benchmark |
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.
|
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
84 |
"""
|
1711.2.82
by John Arbash Meinel
minor fix from Jan Balster to get --benchmark to work again |
85 |
tree = bzrdir.BzrDir.create_standalone_workingtree(directory_name) |
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
86 |
tree.lock_write() |
87 |
try: |
|
1756.2.21
by Aaron Bentley
Clean up merge log benchmark |
88 |
tree2 = tree.bzrdir.sprout('tree2').open_workingtree() |
89 |
tree2.lock_write() |
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
90 |
try: |
1756.2.21
by Aaron Bentley
Clean up merge log benchmark |
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([]) |
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
99 |
finally: |
100 |
tree.unlock() |
|
1756.2.21
by Aaron Bentley
Clean up merge log benchmark |
101 |
finally: |
102 |
tree2.unlock() |
|
1756.2.19
by Aaron Bentley
Add benchmarks for merged trees |
103 |
return tree |
104 |
||
1707.2.2
by Robert Collins
Start on bench_add, an add benchtest. |
105 |
|
106 |
def test_suite(): |
|
107 |
"""Build and return a TestSuite which contains benchmark tests only."""
|
|
108 |
testmod_names = [ \ |
|
109 |
'bzrlib.benchmarks.bench_add', |
|
1755.2.1
by Robert Collins
Add a benchmark for make_kernel_like_tree. |
110 |
'bzrlib.benchmarks.bench_bench', |
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
111 |
'bzrlib.benchmarks.bench_checkout', |
1714.1.5
by Robert Collins
Add commit benchmark. |
112 |
'bzrlib.benchmarks.bench_commit', |
1757.2.10
by Robert Collins
Give all inventory entries __slots__ that are useful with the current codebase. |
113 |
'bzrlib.benchmarks.bench_inventory', |
1756.1.7
by Aaron Bentley
Merge bzr.dev |
114 |
'bzrlib.benchmarks.bench_log', |
1756.1.2
by Aaron Bentley
Show logs using get_revisions |
115 |
'bzrlib.benchmarks.bench_osutils', |
1752.1.2
by Aaron Bentley
Benchmark the rocks command |
116 |
'bzrlib.benchmarks.bench_rocks', |
1714.1.4
by Robert Collins
Add new benchmarks for status and commit. |
117 |
'bzrlib.benchmarks.bench_status', |
1534.10.33
by Aaron Bentley
Add canonicalize_path benchmark |
118 |
'bzrlib.benchmarks.bench_transform', |
1732.1.11
by John Arbash Meinel
Trying multiple things to get WorkingTree.list_files time down |
119 |
'bzrlib.benchmarks.bench_workingtree', |
1707.2.2
by Robert Collins
Start on bench_add, an add benchtest. |
120 |
]
|
1841.1.1
by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests |
121 |
suite = TestLoader().loadTestsFromModuleNames(testmod_names) |
122 |
||
123 |
# Load any benchmarks from plugins
|
|
1711.2.78
by John Arbash Meinel
Cleanup the imports in bzrlib.benchmark |
124 |
for name, module in plugin.all_plugins().items(): |
125 |
if getattr(module, 'bench_suite', None) is not None: |
|
126 |
suite.addTest(module.bench_suite()) |
|
1841.1.1
by John Arbash Meinel
Allow plugins to provide benchmarks just like they do tests |
127 |
|
128 |
return suite |