diff --git a/tools/benchcomp/benchcomp/visualizers/__init__.py b/tools/benchcomp/benchcomp/visualizers/__init__.py index 6efdcd34bd71..6669d044ae29 100644 --- a/tools/benchcomp/benchcomp/visualizers/__init__.py +++ b/tools/benchcomp/benchcomp/visualizers/__init__.py @@ -256,12 +256,15 @@ def _get_template(): quadrant-2 2 quadrant-3 3 quadrant-4 4 - {%- for bench_name, bench_variants in d["scaled_metrics"][metric].items () %} + {%- for bench_name, bench_variants in d["scaled_metrics"][metric]["benchmarks"].items () %} {% set v0 = bench_variants[d["scaled_variants"][metric][0]] -%} {% set v1 = bench_variants[d["scaled_variants"][metric][1]] -%} "{{ bench_name }}": [{{ v0|round(3) }}, {{ v1|round(3) }}] {%- endfor %} ``` + Scatterplot axis ranges are + {{ d["scaled_metrics"][metric]["min_value"] }} (bottom/left) to + {{ d["scaled_metrics"][metric]["max_value"] }} (top/right). {% endif -%} | Benchmark | {% for variant in d["variants"][metric] %} {{ variant }} |{% endfor %} @@ -293,13 +296,17 @@ def _compute_scaled_metric(data_for_metric, log_scaling): min_value = variant_result if max_value is None or variant_result > max_value: max_value = variant_result - ret = {bench: {} for bench in data_for_metric.keys()} + ret = { + "benchmarks": {bench: {} for bench in data_for_metric.keys()}, + "min_value": "log({})".format(min_value) if log_scaling else min_value, + "max_value": "log({})".format(max_value) if log_scaling else max_value, + } # 1.0 is not a permissible value for mermaid, so make sure all scaled # results stay below that by use 0.99 as hard-coded value or # artificially increasing the range by 10 per cent if min_value is None or min_value == max_value: for bench, bench_result in data_for_metric.items(): - ret[bench] = {variant: 0.99 for variant in bench_result.keys()} + ret["benchmarks"][bench] = {variant: 0.99 for variant in bench_result.keys()} else: if log_scaling: min_value = math.log(min_value, 10) @@ -312,7 +319,7 @@ def _compute_scaled_metric(data_for_metric, log_scaling): abs_value = math.log(variant_result, 10) else: abs_value = variant_result - ret[bench][variant] = (abs_value - min_value) / value_range + ret["benchmarks"][bench][variant] = (abs_value - min_value) / value_range return ret @@ -366,6 +373,16 @@ def _get_variants(metrics): return ret + @staticmethod + def _get_scaled_variants(metrics): + ret = {} + for metric, entries in metrics.items(): + for bench, variants in entries["benchmarks"].items(): + ret[metric] = list(variants.keys()) + break + return ret + + def __call__(self, results): (metrics, scaled) = self._organize_results_into_metrics( results, self.scatterplot == Plot.LOG) @@ -375,7 +392,7 @@ def __call__(self, results): "metrics": metrics, "variants": self._get_variants(metrics), "scaled_metrics": scaled, - "scaled_variants": self._get_variants(scaled), + "scaled_variants": self._get_scaled_variants(scaled), } env = jinja2.Environment( diff --git a/tools/benchcomp/test/test_regression.py b/tools/benchcomp/test/test_regression.py index ebe467a6d658..1116e416764e 100644 --- a/tools/benchcomp/test/test_regression.py +++ b/tools/benchcomp/test/test_regression.py @@ -458,6 +458,7 @@ def test_markdown_results_table(self): run_bc() self.assertEqual(run_bc.proc.returncode, 0, msg=run_bc.stderr) + self.maxDiff = None self.assertEqual( run_bc.stdout, textwrap.dedent(""" ## runtime @@ -475,6 +476,10 @@ def test_markdown_results_table(self): "bench_1": [0.0, 0.909] "bench_2": [0.909, 0.0] ``` + Scatterplot axis ranges are + 5 (bottom/left) to + 10 (top/right). + | Benchmark | variant_1 | variant_2 | ratio | | --- | --- | --- | --- |