Mercurial > public > mercurial-scm > hg
comparison contrib/benchmarks/revset.py @ 30406:cff0f5926797
perf: add asv benchmarks
Airspeed velocity (ASV) is a python framework for benchmarking Python packages
over their lifetime. The results are displayed in an interactive web frontend.
Add ASV benchmarks for mercurial that use contrib/perf.py extension that could
be run against multiple reference repositories.
The benchmark suite now includes revsets from contrib/base-revsets.txt with
variants, perftags, perfstatus, perfmanifest and perfheads.
Installation requires asv>=0.2, python-hglib and virtualenv
This is part of PerformanceTrackingSuitePlan
https://www.mercurial-scm.org/wiki/PerformanceTrackingSuitePlan
author | Philippe Pepiot <philippe.pepiot@logilab.fr> |
---|---|
date | Thu, 29 Sep 2016 10:16:34 +0200 |
parents | |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
30405:e77e8876886f | 30406:cff0f5926797 |
---|---|
1 # revset.py - asv revset benchmarks | |
2 # | |
3 # Copyright 2016 Logilab SA <contact@logilab.fr> | |
4 # | |
5 # This software may be used and distributed according to the terms of the | |
6 # GNU General Public License version 2 or any later version. | |
7 | |
8 '''ASV revset benchmarks generated from contrib/base-revsets.txt | |
9 | |
10 Each revset benchmark is parameterized with variants (first, last, sort, ...) | |
11 ''' | |
12 | |
13 from __future__ import absolute_import | |
14 | |
15 import os | |
16 import string | |
17 import sys | |
18 | |
19 from . import basedir, perfbench | |
20 | |
21 def createrevsetbenchmark(baseset, variants=None): | |
22 if variants is None: | |
23 # Default variants | |
24 variants = ["plain", "first", "last", "sort", "sort+first", | |
25 "sort+last"] | |
26 fname = "track_" + "_".join("".join([ | |
27 c if c in string.digits + string.letters else " " | |
28 for c in baseset | |
29 ]).split()) | |
30 | |
31 def wrap(fname, baseset): | |
32 @perfbench(name=baseset, params=[("variant", variants)]) | |
33 def f(perf, variant): | |
34 revset = baseset | |
35 if variant != "plain": | |
36 for var in variant.split("+"): | |
37 revset = "%s(%s)" % (var, revset) | |
38 return perf("perfrevset", revset) | |
39 f.__name__ = fname | |
40 return f | |
41 return wrap(fname, baseset) | |
42 | |
43 def initializerevsetbenchmarks(): | |
44 mod = sys.modules[__name__] | |
45 with open(os.path.join(basedir, 'contrib', 'base-revsets.txt'), | |
46 'rb') as fh: | |
47 for line in fh: | |
48 baseset = line.strip() | |
49 if baseset and not baseset.startswith('#'): | |
50 func = createrevsetbenchmark(baseset) | |
51 setattr(mod, func.__name__, func) | |
52 | |
53 initializerevsetbenchmarks() |