Skip to content

Commit 1bdca78

Browse files
committed
harness add __setup__ entry point
1 parent a6ada6c commit 1bdca78

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

graalpython/benchmarks/src/harness.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,14 @@
4444

4545

4646
_HRULE = '-'.join(['' for i in range(80)])
47-
ATTR_BENCHMARK = '__benchmark__'
47+
48+
#: this function is used to pre-process the arguments as expected by the __benchmark__ and __setup__ entry points
4849
ATTR_PROCESS_ARGS = '__process_args__'
50+
#: gets called with the preprocessed arguments before __benchmark__
51+
ATTR_SETUP = '__setup__'
52+
#: gets called with the preprocessed arguments N times
53+
ATTR_BENCHMARK = '__benchmark__'
54+
#: performs any teardown needed in the benchmark
4955
ATTR_TEARDOWN = '__teardown__'
5056

5157

@@ -146,6 +152,10 @@ def run(self):
146152
print("### args = %s" % args)
147153
print(_HRULE)
148154

155+
print("### setup ... ")
156+
self._call_attr(ATTR_SETUP, *args)
157+
print("### start benchmark ... ")
158+
149159
bench_func = self._get_attr(ATTR_BENCHMARK)
150160
if bench_func and hasattr(bench_func, '__call__'):
151161
if self.warmup:

0 commit comments

Comments
 (0)