Skip to content

Commit

Permalink
Tweak authoring benchmarks section
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Jun 22, 2021
1 parent 378b41f commit 941e969
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 35 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ repository, and the results are hosted on the

- May 2021: https://ursalabs.org/blog/announcing-conbench/

<hr>

<br>


## Index
Expand Down Expand Up @@ -321,7 +322,10 @@ class ExternalBenchmark(conbench.runner.Benchmark):
"time_unit": "s",
}
return self.conbench.external(data, self.name, options=kwargs, output=data)
context = {"benchmark_language": "C++"}
return self.conbench.external(
data, self.name, context=context, options=kwargs, output=data
)
```


Expand All @@ -334,10 +338,6 @@ $ conbench external --help
Run external benchmark.
Options:
--iterations INTEGER [default: 1]
--drop-caches BOOLEAN [default: False]
--gc-collect BOOLEAN [default: True]
--gc-disable BOOLEAN [default: True]
--show-result BOOLEAN [default: True]
--show-output BOOLEAN [default: False]
--run-id TEXT Group executions together with a run id.
Expand Down
45 changes: 16 additions & 29 deletions conbench/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,9 @@ def __init__(self):
self._drop_caches_failed = False
self._purge_failed = False

def run(
self,
f,
name,
tags=None,
context=None,
github=None,
options=None,
):
tags = tags if tags is not None else {}
context = context if context is not None else {}
options = options if options is not None else {}
github = github if github is not None else self.get_github_info()

def run(self, f, name, **kwargs):
"""Benchmark a function and publish the result."""
tags, context, github, options, _ = self._init(kwargs)
benchmark, output = self.benchmark(
f,
name,
Expand All @@ -143,21 +132,9 @@ def run(
self.publish(benchmark)
return [(benchmark, output)]

def external(
self,
r,
name,
tags=None,
context=None,
github=None,
options=None,
output=None,
):
tags = tags if tags is not None else {}
context = context if context is not None else {}
options = options if options is not None else {}
github = github if github is not None else self.get_github_info()

def external(self, r, name, **kwargs):
"""Record and publish an external benchmark result."""
tags, context, github, options, output = self._init(kwargs)
benchmark, output = self.record(
r,
name,
Expand All @@ -170,7 +147,16 @@ def external(
self.publish(benchmark)
return [(benchmark, output)]

def _init(self, kwargs):
tags = kwargs.get("tags", {})
context = kwargs.get("context", {})
github = kwargs.get("github", {})
options = kwargs.get("options", {})
github = github if github is not None else self.get_github_info()
return tags, context, github, options, kwargs.get("output")

def benchmark(self, f, name, tags, context, github, options):
"""Benchmark a function."""
timing_options = self._get_timing_options(options)
iterations = timing_options.pop("iterations")
if iterations < 1:
Expand All @@ -189,6 +175,7 @@ def benchmark(self, f, name, tags, context, github, options):
return benchmark, output

def record(self, result, name, tags, context, github, options, output=None):
"""Create a record for an external benchmark result."""
tags["name"] = name
timestamp = _now_formatted()
run_id = options.get("run_id")
Expand Down

0 comments on commit 941e969

Please sign in to comment.