# HG changeset patch # User Gregory Szorc # Date 2015-11-21 23:39:18 # Node ID e18a9ceade3b44863e4ac3b7ae7c47b98cf49ee0 # Parent dfb31eebd9493d3a8f15f3d4509db0afeffd2acf 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. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -463,9 +463,10 @@ def perfrevlog(ui, repo, file_, **opts): 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 perfrevset(ui, repo, expr, clear=Fal 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()