Rev 6: Include a timing section with repeated strings. in http://bzr.arbash-meinel.com/plugins/bench_patience
John Arbash Meinel
john at arbash-meinel.com
Wed Dec 19 15:45:28 GMT 2007
At http://bzr.arbash-meinel.com/plugins/bench_patience
------------------------------------------------------------
revno: 6
revision-id:john at arbash-meinel.com-20071219154240-39k5kn6q94vsi1g8
parent: john at arbash-meinel.com-20071219153322-lgp0eh361sgze492
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bench_patience
timestamp: Wed 2007-12-19 09:42:40 -0600
message:
Include a timing section with repeated strings.
modified:
__init__.py __init__.py-20071204154123-hrdofqdugj0iwxcy-1
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2007-12-19 15:33:22 +0000
+++ b/__init__.py 2007-12-19 15:42:40 +0000
@@ -50,6 +50,7 @@
self.outf.write('%d total bytes\n' % total_len)
last_text = []
from bzrlib.patiencediff import PatienceSequenceMatcher
+ # Using unique texts
times = []
pb = ui.ui_factory.nested_progress_bar()
try:
@@ -72,7 +73,32 @@
avg = sum_time / float(len(times))
max_time = max(times)
min_time = min(times)
- print 'Total: %.3fs/%.3fs, min: %.3fms avg: %.3fms max: %.3fms' % (
+ print 'Total Unique: %.3fs/%.3fs, min: %.3fms avg: %.3fms max: %.3fms' % (
+ total_time, sum_time, min_time*1000, avg*1000, max_time*1000)
+ # Using repeated texts
+ last_text = []
+ times = []
+ pb = ui.ui_factory.nested_progress_bar()
+ try:
+ t_overall_start = time.clock()
+ total_time = 0
+ for idx, text in enumerate(texts):
+ # Make sure all the strings are brand new
+ pb.update('comparing', idx, len(texts))
+ t_start = time.clock()
+ matcher = PatienceSequenceMatcher(None, last_text, text)
+ matcher.get_matching_blocks()
+ t_delta = time.clock() - t_start
+ times.append(t_delta)
+ last_text = text
+ total_time = time.clock() - t_overall_start
+ finally:
+ pb.finished()
+ sum_time = sum(times)
+ avg = sum_time / float(len(times))
+ max_time = max(times)
+ min_time = min(times)
+ print 'Total Repeat: %.3fs/%.3fs, min: %.3fms avg: %.3fms max: %.3fms' % (
total_time, sum_time, min_time*1000, avg*1000, max_time*1000)
finally:
tree.unlock()
More information about the bazaar-commits
mailing list