16 import string |
16 import string |
17 import sys |
17 import sys |
18 |
18 |
19 from . import basedir, perfbench |
19 from . import basedir, perfbench |
20 |
20 |
|
21 |
21 def createrevsetbenchmark(baseset, variants=None): |
22 def createrevsetbenchmark(baseset, variants=None): |
22 if variants is None: |
23 if variants is None: |
23 # Default variants |
24 # Default variants |
24 variants = ["plain", "first", "last", "sort", "sort+first", |
25 variants = ["plain", "first", "last", "sort", "sort+first", "sort+last"] |
25 "sort+last"] |
26 fname = "track_" + "_".join( |
26 fname = "track_" + "_".join("".join([ |
27 "".join( |
27 c if c in string.digits + string.letters else " " |
28 [c if c in string.digits + string.letters else " " for c in baseset] |
28 for c in baseset |
29 ).split() |
29 ]).split()) |
30 ) |
30 |
31 |
31 def wrap(fname, baseset): |
32 def wrap(fname, baseset): |
32 @perfbench(name=baseset, params=[("variant", variants)]) |
33 @perfbench(name=baseset, params=[("variant", variants)]) |
33 def f(perf, variant): |
34 def f(perf, variant): |
34 revset = baseset |
35 revset = baseset |
35 if variant != "plain": |
36 if variant != "plain": |
36 for var in variant.split("+"): |
37 for var in variant.split("+"): |
37 revset = "%s(%s)" % (var, revset) |
38 revset = "%s(%s)" % (var, revset) |
38 return perf("perfrevset", revset) |
39 return perf("perfrevset", revset) |
|
40 |
39 f.__name__ = fname |
41 f.__name__ = fname |
40 return f |
42 return f |
|
43 |
41 return wrap(fname, baseset) |
44 return wrap(fname, baseset) |
|
45 |
42 |
46 |
43 def initializerevsetbenchmarks(): |
47 def initializerevsetbenchmarks(): |
44 mod = sys.modules[__name__] |
48 mod = sys.modules[__name__] |
45 with open(os.path.join(basedir, 'contrib', 'base-revsets.txt'), |
49 with open(os.path.join(basedir, 'contrib', 'base-revsets.txt'), 'rb') as fh: |
46 'rb') as fh: |
|
47 for line in fh: |
50 for line in fh: |
48 baseset = line.strip() |
51 baseset = line.strip() |
49 if baseset and not baseset.startswith('#'): |
52 if baseset and not baseset.startswith('#'): |
50 func = createrevsetbenchmark(baseset) |
53 func = createrevsetbenchmark(baseset) |
51 setattr(mod, func.__name__, func) |
54 setattr(mod, func.__name__, func) |
52 |
55 |
|
56 |
53 initializerevsetbenchmarks() |
57 initializerevsetbenchmarks() |