Rev 4: Force all of the texts to have completely unique strings before doing the comparison. in http://bzr.arbash-meinel.com/plugins/bench_patience
John Arbash Meinel
john at arbash-meinel.com
Wed Dec 5 00:17:41 GMT 2007
At http://bzr.arbash-meinel.com/plugins/bench_patience
------------------------------------------------------------
revno: 4
revision-id:john at arbash-meinel.com-20071205001636-9fvdex40n983rz3w
parent: john at arbash-meinel.com-20071204235627-07ldd8e3pk51jo15
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bench_patience
timestamp: Tue 2007-12-04 18:16:36 -0600
message:
Force all of the texts to have completely unique strings before doing the comparison.
modified:
__init__.py __init__.py-20071204154123-hrdofqdugj0iwxcy-1
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2007-12-04 23:56:27 +0000
+++ b/__init__.py 2007-12-05 00:16:36 +0000
@@ -43,31 +43,32 @@
texts = w.get_line_list(versions)
total_len = sum(len(t) for t in texts)
self.outf.write('%d total bytes\n' % total_len)
- last_text = None
+ last_text = []
from bzrlib.patiencediff import PatienceSequenceMatcher
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
+ text = [l[:10] + l[10:] for l in text]
pb.update('comparing', idx, len(texts))
- if last_text is None:
- last_text = text
- continue
+ t_start = time.clock()
matcher = PatienceSequenceMatcher(None, last_text, text)
- last_text = None
- t_start = time.clock()
matcher.get_matching_blocks()
t_delta = time.clock() - t_start
times.append(t_delta)
+ last_text = [l[:10] + l[10:] for l in text]
total_time = time.clock() - t_overall_start
finally:
pb.finished()
- avg = sum(times) / float(len(times))
+ sum_time = sum(times)
+ avg = sum_time / float(len(times))
max_time = max(times)
min_time = min(times)
- print 'Total: %.3fs, min: %.3fms avg: %.3fms max: %.3fms' % (
- total_time, min_time*1000, avg*1000, max_time*1000)
+ print 'Total: %.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