Skip to content

Commit d009a6c

Browse files
committed
[GR-18377] Fix benchmark scoring.
PullRequest: graalpython/662
2 parents 225f2c8 + 78b93a2 commit d009a6c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,22 @@ def rules(self, output, benchmarks, bm_suite_args):
357357
"config.run-flags": "".join(arg),
358358
}
359359
),
360+
# secondary metric(s)
361+
StdOutRule(
362+
r"### WARMUP detected at iteration: (?P<endOfWarmup>[0-9]+$)",
363+
{
364+
"benchmark": '{}.{}'.format(self._name, bench_name),
365+
"metric.name": "end-of-warmup",
366+
"metric.iteration": 0,
367+
"metric.type": "numeric",
368+
"metric.value": ("<endOfWarmup>", int),
369+
"metric.unit": "s",
370+
"metric.score-function": "id",
371+
"metric.better": "lower",
372+
"config.run-flags": "".join(arg),
373+
}
374+
),
375+
360376
# no warmups
361377
StdOutRule(
362378
r"^@@@ name=(?P<benchmark>[a-zA-Z0-9._\-]+), duration=(?P<time>[0-9]+(\.[0-9]+)?$)", # pylint: disable=line-too-long
@@ -375,9 +391,9 @@ def rules(self, output, benchmarks, bm_suite_args):
375391
]
376392

377393
def runAndReturnStdOut(self, benchmarks, bmSuiteArgs):
378-
# host-vm rewrite rules
379394
ret_code, out, dims = super(PythonBenchmarkSuite, self).runAndReturnStdOut(benchmarks, bmSuiteArgs)
380395

396+
# host-vm rewrite rules
381397
def _replace_host_vm(key):
382398
host_vm = dims.get("host-vm")
383399
if host_vm and host_vm.startswith(key):
@@ -450,10 +466,20 @@ def createVmCommandLineArgs(self, benchmarks, bmSuiteArgs):
450466

451467
if "-i" not in run_args:
452468
run_args += self._benchmarks[benchmark]
469+
num_iterations = self.defaultIterations(benchmark) + self.getExtraIterationCount(self.defaultIterations(benchmark))
470+
run_args[run_args.index("-i") + 1] = str(num_iterations)
453471
vm_options, run_args = self.postprocess_run_args(run_args)
454472
cmd_args.extend(run_args)
455473
return vm_options + vm_args + cmd_args
456474

475+
def defaultIterations(self, bm):
476+
default_bench_args = self._benchmarks[bm]
477+
if "-i" in default_bench_args:
478+
bench_idx = default_bench_args.index("-i")
479+
if bench_idx + 1 < len(default_bench_args):
480+
return int(default_bench_args[bench_idx + 1])
481+
return DEFAULT_ITERATIONS
482+
457483
def benchmarkList(self, bm_suite_args):
458484
return list(self._benchmarks.keys())
459485

0 commit comments

Comments
 (0)