perftest: add a command to benchmark construction of volatile cache
Obsolescence and filtering related caches are critical. Having a handy way to
check them is valuable.
--- a/contrib/perf.py Fri Jan 04 19:22:40 2013 +0100
+++ b/contrib/perf.py Fri Jan 04 19:23:26 2013 +0100
@@ -1,7 +1,8 @@
# 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 = {}
@@ -275,3 +276,28 @@
repo.invalidatevolatilesets()
repo.revs(expr)
timer(d)
+
+@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)