Skip to content

Commit

Permalink
Don't produce 1.0 value
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Mar 15, 2024
1 parent 7769fff commit 37aea31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion tools/benchcomp/benchcomp/visualizers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,18 @@ def _compute_scaled_metric(data_for_metric, log_scaling):
if max_value is None or variant_result > max_value:
max_value = variant_result
ret = {bench: {} for bench in data_for_metric.keys()}
# 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: 1.0 for variant in bench_result.keys()}
ret[bench] = {variant: 0.99 for variant in bench_result.keys()}
else:
if log_scaling:
min_value = math.log(min_value, 10)
max_value = math.log(max_value, 10)
value_range = max_value - min_value
value_range = value_range * 1.1
for bench, bench_result in data_for_metric.items():
for variant, variant_result in bench_result.items():
if log_scaling:
Expand Down
4 changes: 2 additions & 2 deletions tools/benchcomp/test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ def test_markdown_results_table(self):
quadrant-2 2
quadrant-3 3
quadrant-4 4
"bench_1": [0.0, 1.0]
"bench_2": [1.0, 0.0]
"bench_1": [0.0, 0.909]
"bench_2": [0.909, 0.0]
```
| Benchmark | variant_1 | variant_2 | ratio |
Expand Down

0 comments on commit 37aea31

Please sign in to comment.