Skip to content

Commit 50deacf

Browse files
committed
fix: hide performance gains without vm telemetry
1 parent a6aec64 commit 50deacf

3 files changed

Lines changed: 28 additions & 13 deletions

File tree

modules/local/render_benchmark_report/bin/benchmark_report_render.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def render_html(
8686
) -> None:
8787
brand = brand or load_brand()
8888
template = Environment(loader=BaseLoader()).from_string(REPORT_TEMPLATE)
89+
run_metrics = data.get("run_metrics") or []
90+
has_performance_gains = any((row or {}).get("vmCpuH") for row in run_metrics)
8991
html = template.render(
9092
generated_at=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
9193
data_json=json.dumps(data, default=str),
@@ -99,6 +101,7 @@ def render_html(
99101
brand_white=brand["white"],
100102
brand_palette=brand["palette"],
101103
logo_svg=logo_svg or "",
104+
has_performance_gains=has_performance_gains,
102105
**data,
103106
)
104107
output_path.write_text(html)

modules/local/render_benchmark_report/bin/benchmark_report_template.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@
208208
<a href="#task-overview"><svg class="nav-icon"><use href="#ic-task"/></svg> Task overview</a>
209209
<a href="#task-instance-usage" class="l2"><svg class="nav-icon"><use href="#ic-instance"/></svg> Instance usage</a>
210210
<a href="#task-metrics" class="l2"><svg class="nav-icon"><use href="#ic-scatter"/></svg> Task metrics</a>
211+
{% if has_performance_gains %}
211212
<a href="#performance-gains"><svg class="nav-icon"><use href="#ic-benchmark"/></svg> Performance gains</a>
213+
{% endif %}
212214
</div>
213215

214216
<div class="main-content">
@@ -440,6 +442,7 @@ <h2 id="task-metrics"><svg class="h-icon sm"><use href="#ic-scatter"/></svg> Tas
440442
</div>
441443

442444
<!-- 6. Performance gains -->
445+
{% if has_performance_gains %}
443446
<div class="section" id="performance-gains">
444447
<h1><svg class="h-icon"><use href="#ic-benchmark"/></svg> Performance gains</h1>
445448
<p class="section-desc">Capacity mix and savings attribution across CPU and memory.</p>
@@ -507,6 +510,7 @@ <h2 id="pg-cpu-savings"><svg class="h-icon sm"><use href="#ic-chart"/></svg> Sav
507510
<h2 id="pg-mem-savings"><svg class="h-icon sm"><use href="#ic-chart"/></svg> Savings attribution (Memory)</h2>
508511
<div class="chart" id="chart-pg-mem-savings"></div>
509512
</div>
513+
{% endif %}
510514

511515
</div>
512516
</div>

modules/local/render_benchmark_report/tests/test_render.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,8 @@ def test_render_html(tmp_path, minimal_report_data):
4141
assert "realVmCpuEfficiency" in text
4242
assert "How process runtime is measured" in text
4343
assert "How task timing is measured" in text
44-
assert "How savings attribution is measured" in text
45-
assert "How savings layers are defined" in text
46-
assert "runs without a Scheduler compute environment" in text
47-
assert "Scheduler rightsize will be zero by construction" in text
48-
# VM metric charts
49-
assert 'id="chart-vm-alloc-cpu"' in text
44+
# Performance gains section — hidden when no VM telemetry
45+
5046
assert 'id="chart-vm-alloc-mem"' in text
5147
assert 'id="chart-vm-real-cpu"' in text
5248
assert 'id="chart-vm-real-mem"' in text
@@ -58,19 +54,31 @@ def test_render_html(tmp_path, minimal_report_data):
5854
assert "Real VM CPU eff %" in text
5955
assert "Real VM Mem eff %" in text
6056
assert "fmtPct(r.realVmCpuEfficiency)" in text
61-
# Performance gains section
57+
# Performance gains section — hidden when no VM telemetry
58+
assert 'id="performance-gains"' not in text
59+
assert 'href="#performance-gains"' not in text
60+
assert 'id="chart-pg-cpu-mix"' not in text
61+
assert 'id="chart-pg-cpu-savings"' not in text
62+
assert 'target="_blank" rel="noopener noreferrer"' in text
63+
assert "r.runUrl ? '<a href=\"' + r.runUrl" in text
64+
65+
66+
def test_render_performance_gains_with_vm_data(tmp_path, minimal_report_data):
67+
data = dict(minimal_report_data)
68+
data["run_metrics"] = [{"group": "cpu", "run_id": "run1", "vmCpuH": 10.0}]
69+
out = tmp_path / "report.html"
70+
render_html(data, out)
71+
text = out.read_text()
6272
assert 'id="performance-gains"' in text
6373
assert 'href="#performance-gains"' in text
6474
assert 'id="chart-pg-cpu-mix"' in text
65-
assert 'id="chart-pg-mem-mix"' in text
6675
assert 'id="chart-pg-cpu-savings"' in text
67-
assert 'id="chart-pg-mem-savings"' in text
76+
assert "How savings attribution is measured" in text
77+
assert "How savings layers are defined" in text
78+
assert "runs without a Scheduler compute environment" in text
79+
assert "Scheduler rightsize will be zero by construction" in text
6880
assert "CPU capacity mix" in text
6981
assert "Savings attribution (CPU) by layer" in text
70-
assert "schedulerRightsizedCpuH" in text
71-
assert "vmPackingSlackCpuH" in text
72-
assert 'target="_blank" rel="noopener noreferrer"' in text
73-
assert "r.runUrl ? '<a href=\"' + r.runUrl" in text
7482

7583

7684
def test_render_includes_combined_runtime_section(tmp_path, minimal_report_data):

0 commit comments

Comments
 (0)