perf: add perfrevlog function to check performance of revlog
authorPradeepkumar Gayam <in3xes@gmail.com>
Tue, 27 Jul 2010 20:50:09 +0530
changeset 11694 bf49d48e4602
parent 11693 ff33f937a7da
child 11695 ee8f36a6c766
perf: add perfrevlog function to check performance of revlog
contrib/perf.py
--- a/contrib/perf.py	Tue Jul 27 01:16:38 2010 +0530
+++ b/contrib/perf.py	Tue Jul 27 20:50:09 2010 +0530
@@ -133,6 +133,16 @@
         title = 'diffopts: %s' % (diffopt and ('-' + diffopt) or 'none')
         timer(d, title)
 
+def perfrevlog(ui, repo, file_, **opts):
+    from mercurial import revlog
+    dist = opts['dist']
+    def d():
+        r = revlog.revlog(lambda fn: open(fn, 'rb'), file_)
+        for x in xrange(0, len(r), dist):
+            r.revision(r.node(x))
+
+    timer(d)
+
 cmdtable = {
     'perflookup': (perflookup, []),
     'perfparents': (perfparents, []),
@@ -149,4 +159,5 @@
                 [('', 'rename', False, 'ask log to follow renames')]),
     'perftemplating': (perftemplating, []),
     'perfdiffwd': (perfdiffwd, []),
+    'perfrevlog': (perfrevlog, [('d', 'dist', 100, 'distance between the revisions')],"[INDEXFILE]"),
 }