Patchwork [2,of,6,frozen-repos] perf: support obtaining contexts from perfrevset

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 22, 2015, 1:13 a.m.
Message ID <2dd44d0377a2a9f7266e.1448154839@ubuntu-main>
Download mbox | patch
Permalink /patch/11566/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Gregory Szorc - Nov. 22, 2015, 1:13 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1448149158 28800
#      Sat Nov 21 15:39:18 2015 -0800
# Node ID 2dd44d0377a2a9f7266e156dc262737e0139c7af
# Parent  e6778f6f5ada8a50bfd7e154334692c404383315
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.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -458,29 +458,33 @@  def perfrevlog(ui, repo, file_, **opts):
         r = revlog.revlog(lambda fn: open(fn, 'rb'), file_)
         for x in xrange(0, len(r), dist):
             r.revision(r.node(x))
 
     timer(d)
     fm.end()
 
 @command('perfrevset',
-         [('C', 'clear', False, 'clear volatile cache between each call.')]
+         [('C', 'clear', False, 'clear volatile cache between each call.'),
+          ('x', '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
     revisions set cache on the revset execution. Volatile cache hold filtered
     and obsolete related cache."""
     timer, fm = gettimer(ui, opts)
     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()
 
 @command('perfvolatilesets', formatteropts)
 def perfvolatilesets(ui, repo, *names, **opts):
     """benchmark the computation of various volatile set
 
     Volatile set computes element related to filtering and obsolescence."""