Patchwork [5,of,6] perftest: add a command to benchmark construction of volatile cache

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 4, 2013, 6:28 p.m.
Message ID <c5a98600c967a317ea29.1357324132@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/396/
State Accepted
Commit a8318715d8bb6c473f0178a942402dbad586b6cb
Headers show

Comments

Pierre-Yves David - Jan. 4, 2013, 6:28 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357323806 -3600
# Node ID c5a98600c967a317ea290a7a78ce9cfce614842b
# Parent  8ff4097ce3bc5930a133fccead9c24dfe3318996
perftest: add a command to benchmark construction of volatile cache

Obsolescence and filtering related caches are critical. Having an handy way to
check them is valuable.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1,9 +1,10 @@ 
 # perf.py - performance test routines
 '''helper extension to measure performance'''
 
-from mercurial import cmdutil, scmutil, util, match, commands
+from mercurial import cmdutil, scmutil, util, match, commands, obsolete
+from mercurial import repoview
 import time, os, sys
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
 
@@ -273,5 +274,30 @@  def perfrevset(ui, repo, expr, clear=Fal
     def d():
         if clear:
             repo.invalidatevolatilesets()
         repo.revs(expr)
     timer(d)
+
+ at command('perfvolatilesets')
+def perfvolatilesets(ui, repo):
+    """benchmark the computation of various volatile set
+
+    Volatile set computes element related to filtering and obsolescence."""
+    repo = repo.unfiltered()
+
+    def getobs(name):
+        def d():
+            repo.invalidatevolatilesets()
+            obsolete.getrevs(repo, name)
+        return d
+
+    for name in sorted(obsolete.cachefuncs):
+        timer(getobs(name), title=name)
+
+    def getfiltered(name):
+        def d():
+            repo.invalidatevolatilesets()
+            repoview.filteredrevs(repo, name)
+        return d
+
+    for name in sorted(repoview.filtertable):
+        timer(getfiltered(name), title=name)