From ea739ad1e71c4df8d85a7f5215fbab783fb0997f Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Thu, 2 Apr 2026 02:46:58 +0000 Subject: [PATCH] Make Julia suite respect benchmark timeout --- docs/src/references/suite.md | 16 ++++++++++++++++ src/running/suite.py | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/src/references/suite.md b/docs/src/references/suite.md index 4210175..7cd0378 100644 --- a/docs/src/references/suite.md +++ b/docs/src/references/suite.md @@ -212,6 +212,9 @@ GC benchmarks for Julia: https://github.com/JuliaCI/GCBenchmarks The value is required. Environment variables will be expanded. +`timeout`: timeout for one invocation of a benchmark in seconds. +The default value is `null`. + `minheap`: a string that selects one of the `minheap_values` sets to use. `minheap_values`: a dictionary containing multiple named sets of minimal heap sizes that is enough for a benchmark from the suite to run without triggering `Out of Memory!`. @@ -231,3 +234,16 @@ An example looks like this: slow/bigint/pidigits: 198 slow/rb_tree/rb_tree: 8640 ``` + +### Benchmark Specification +Benchmarks can be specified either as strings or as dictionaries. + +The keys currently supported in the dictionary form are `name` and `timeout`. + +Example: +```yaml +benchmarks: + gcbenchmarks: + - name: serial/gcbench/gcbench + timeout: 30 +``` diff --git a/src/running/suite.py b/src/running/suite.py index 8146aa8..6f0ca13 100644 --- a/src/running/suite.py +++ b/src/running/suite.py @@ -489,6 +489,8 @@ def __init__(self, **kwargs): self.name, self.name ) ) + self.timeout: Optional[int] + self.timeout = kwargs.get("timeout") def __str__(self) -> str: return "{} JuliaGCBenchmarks {}".format(super().__str__(), self.path) @@ -505,13 +507,25 @@ def get_minheap(self, bm: Benchmark) -> int: return minheap[name] def get_benchmark(self, bm_spec: Union[str, Dict[str, Any]]) -> "JuliaBenchmark": - assert type(bm_spec) is str + timeout = self.timeout + if type(bm_spec) is str: + name = bm_spec + else: + assert type(bm_spec) is dict + if "name" not in bm_spec: + raise KeyError( + "When a dictionary is used to specify a benchmark, you need to provide `name`" + ) + name = bm_spec["name"] + if "timeout" in bm_spec: + timeout = bm_spec["timeout"] return JuliaBenchmark( julia_args=[], suite_name=self.name, - name=bm_spec, + name=name, suite_path=self.path, program_args=[], + timeout=timeout, ) def is_passed(self, output: bytes) -> bool: