# HG changeset patch # User Gregory Szorc # Date 1448149158 28800 # 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 -r dfb31eebd949 -r e18a9ceade3b 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()