perf: support obtaining contexts from perfrevset
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 21 Nov 2015 15:39:18 -0800
changeset 27072 e18a9ceade3b
parent 27071 dfb31eebd949
child 27073 b9fc042168a4
perf: support obtaining contexts from perfrevset Previously, perfrevset called repo.revs(), which only returns integer revisions. Many revset consumers call repo.set(), which returns changectx instances. Or they obtain a context manually later. Since obtaining changectx instances when evaluating revsets is common, this patch adds support for benchmarking this use case. While we added an if conditional for every benchmark loop, it doesn't appear to matter since revset evaluation dwarfs the cost of a single if.
contrib/perf.py
--- a/contrib/perf.py	Sat Nov 21 11:07:30 2015 -0800
+++ b/contrib/perf.py	Sat Nov 21 15:39:18 2015 -0800
@@ -463,9 +463,10 @@
     fm.end()
 
 @command('perfrevset',
-         [('C', 'clear', False, 'clear volatile cache between each call.')]
+         [('C', 'clear', False, 'clear volatile cache between each call.'),
+          ('', 'contexts', False, 'obtain changectx for each revision')]
          + formatteropts, "REVSET")
-def perfrevset(ui, repo, expr, clear=False, **opts):
+def perfrevset(ui, repo, expr, clear=False, contexts=False, **opts):
     """benchmark the execution time of a revset
 
     Use the --clean option if need to evaluate the impact of build volatile
@@ -475,7 +476,10 @@
     def d():
         if clear:
             repo.invalidatevolatilesets()
-        for r in repo.revs(expr): pass
+        if contexts:
+            for ctx in repo.set(expr): pass
+        else:
+            for r in repo.revs(expr): pass
     timer(d)
     fm.end()