13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Tests for bzr bundle performance."""
23
23
from bzrlib import bzrdir
24
from bzrlib.add import smart_add
25
24
from bzrlib.benchmarks import Benchmark
26
25
from bzrlib.branch import Branch
27
26
from bzrlib.bundle.apply_bundle import install_bundle
34
33
class BundleBenchmark(Benchmark):
35
34
"""Benchmarks for bzr bundle performance and bzr merge with a bundle."""
37
36
def test_create_bundle_known_kernel_like_tree(self):
38
37
"""Create a bundle for a kernel sized tree with no ignored, unknowns,
39
38
or added and one commit.
41
40
self.make_kernel_like_committed_tree()
42
self.time(self.run_bzr, 'bundle', '--revision', '..-1')
41
self.time(self.run_bzr, ['bundle', '--revision', '..-1'])
44
43
def test_create_bundle_many_commit_tree (self):
45
"""Create a bundle for a tree with many commits but no changes."""
44
"""Create a bundle for a tree with many commits but no changes."""
46
45
self.make_many_commit_tree()
47
self.time(self.run_bzr, 'bundle', '--revision', '..-1')
46
self.time(self.run_bzr, ['bundle', '--revision', '..-1'])
49
48
def test_create_bundle_heavily_merged_tree(self):
50
"""Create a bundle for a heavily merged tree."""
49
"""Create a bundle for a heavily merged tree."""
51
50
self.make_heavily_merged_tree()
52
self.time(self.run_bzr, 'bundle', '--revision', '..-1')
51
self.time(self.run_bzr, ['bundle', '--revision', '..-1'])
54
53
def test_apply_bundle_known_kernel_like_tree(self):
55
54
"""Create a bundle for a kernel sized tree with no ignored, unknowns,
56
55
or added and one commit.
58
57
tree = self.make_kernel_like_committed_tree('tree')
60
59
f = open('bundle', 'wb')
67
66
tree2 = self.make_branch_and_tree('branch_a')
68
67
os.chdir('branch_a')
69
self.time(self.run_bzr, 'merge', '../bundle')
68
self.time(self.run_bzr, ['merge', '../bundle'])
72
71
class BundleLibraryLevelWriteBenchmark(Benchmark):
73
72
""" Benchmarks for the write_bundle library function. """
186
185
if __name__ == '__main__':
187
# USE the following if you want to regenerate the above test functions
186
# USE the following if you want to regenerate the above test functions
188
187
for treesize, treesize_h in [(5, "small"), (100, "moderate"),
190
189
for bundlefiles, bundlefiles_h in [(5, "few"), (100, "some")]:
191
190
if bundlefiles > treesize:
193
192
for num_revisions in [1, 100]:
194
if (num_revisions >= 100 and
193
if (num_revisions >= 100 and
195
194
(bundlefiles >= 100 or treesize >= 1000)):
196
195
# Skip the 100x100x? tests.
197
196
# And the 100x?x1000