Add benchmark list sub-command.

This commit is contained in:
François Saint-Jacques committed 2019-05-27 15:40:42 -04:00
1 parent e0876474b7
commit ffe723f054
2 files changed
+41 -1

No files matched your search

+7
View File
@@ -146,6 +146,13 @@ class CppBenchmarkRunner(BenchmarkRunner):
benchmarks = GoogleBenchmark.from_json(results.get("benchmarks"))
return BenchmarkSuite(name, benchmarks)
@property
def list(self):
for suite_name, suite_bin in self.suites_binaries.items():
suite_cmd = GoogleBenchmarkCommand(suite_bin)
for benchmark_name in suite_cmd.list_benchmarks():
yield f"{suite_name}.{benchmark_name}"
@property
def suites(self):
""" Returns all suite for a runner. """
+34 -1
View File
@@ -173,6 +173,39 @@ def benchmark(ctx):
pass
@benchmark.command(name="list", short_help="List benchmark suite")
@click.option("--src", metavar="<arrow_src>", show_default=True,
default=ArrowSources.find(),
callback=validate_arrow_sources,
help="Specify Arrow source directory")
@click.option("--preserve", type=bool, default=False, show_default=True,
is_flag=True, help="Preserve workspace for investigation.")
@click.option("--output", metavar="<output>",
type=click.File("w", encoding="utf8"), default="-",
help="Capture output result into file.")
@click.option("--cmake-extras", type=str, multiple=True,
help="Extra flags/options to pass to cmake invocation. "
"Can be stacked")
@click.argument("baseline", metavar="[<baseline>]", default="WORKSPACE",
required=False)
@click.pass_context
def benchmark_list(ctx, src, preserve, output, cmake_extras, baseline):
""" List benchmark suite.
"""
with tmpdir(preserve) as root:
logger.debug(f"Running benchmark {baseline}")
conf = CppConfiguration(
build_type="release", with_tests=True, with_benchmarks=True,
with_python=False, cmake_extras=cmake_extras)
runner_base = BenchmarkRunner.from_rev_or_path(
src, root, baseline, conf)
for b in runner_base.list:
print(b, file=output)
@benchmark.command(name="run", short_help="Run benchmark suite")
@click.option("--src", metavar="<arrow_src>", show_default=True,
default=ArrowSources.find(),
@@ -191,7 +224,7 @@ def benchmark(ctx):
@click.option("--cmake-extras", type=str, multiple=True,
help="Extra flags/options to pass to cmake invocation. "
"Can be stacked")
@click.argument("baseline", metavar="[<baseline>]]", default="master",
@click.argument("baseline", metavar="[<baseline>]", default="WORKSPACE",
required=False)
@click.pass_context
def benchmark_run(ctx, src, preserve, suite_filter, benchmark_filter,