Skip to content

Commit c58b771

Browse files
authored
Add support for multiple benchmark groups in a manifest (#192)
1 parent febe2f1 commit c58b771

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

pyperformance/_manifest.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,17 @@ def _add_sections(self, sections, resolve):
117117
_resolve = resolve_default_benchmark
118118
lastfile = filename
119119

120+
section_key = section
121+
if section == "group":
122+
section_key = (section, data[0])
123+
120124
if filename not in sections_seen:
121-
sections_seen[filename] = {section}
122-
elif section in sections_seen[filename]:
123-
# For now each section can only show up once.
124-
raise NotImplementedError((section, data))
125+
sections_seen[filename] = {section_key}
126+
elif section_key in sections_seen[filename]:
127+
# For now each section_key can only show up once.
128+
raise NotImplementedError((section_key, data))
125129
else:
126-
sections_seen[filename].add(section)
130+
sections_seen[filename].add(section_key)
127131

128132
if section == 'includes':
129133
pass
@@ -416,20 +420,20 @@ def _resolve_groups(rawgroups, byname):
416420
while unresolved:
417421
for groupname, names in list(unresolved.items()):
418422
benchmarks = set()
419-
for name in names:
423+
424+
q = list(names)
425+
while q:
426+
name = q.pop()
427+
420428
if name in byname:
421429
benchmarks.add(byname[name])
422430
elif name in groups:
423431
benchmarks.update(groups[name])
424-
names.remove(name)
425432
elif name == groupname:
426-
names.remove(name)
427-
break
433+
pass
428434
else: # name in unresolved
429-
names.remove(name)
430-
names.extend(unresolved[name])
431-
break
432-
else:
433-
groups[groupname] = benchmarks
434-
del unresolved[groupname]
435+
q.extend(unresolved[name])
436+
437+
groups[groupname] = benchmarks
438+
del unresolved[groupname]
435439
return groups

pyperformance/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def filter_opts(cmd, *, allow_no_benchmarks=False):
2929
cmd.add_argument("--manifest", help="benchmark manifest file to use")
3030

3131
cmd.add_argument("-b", "--benchmarks", metavar="BM_LIST", default='<default>',
32-
help=("Comma-separated list of benchmarks to run. Can"
32+
help=("Comma-separated list of benchmarks or groups to run. Can"
3333
" contain both positive and negative arguments:"
3434
" --benchmarks=run_this,also_this,-not_this. If"
3535
" there are no positive arguments, we'll run all"

0 commit comments

Comments
 (0)