Files
HealthAppRepository/tools/energy-jmeter/report-template.html
T

26 lines
5.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html><html lang="en"><meta charset="utf-8"><title>HealthApp measurement report</title>
<style>body{font:15px system-ui;margin:24px;background:#f6f8fb;color:#182230}header,section{background:white;padding:18px;margin-bottom:16px;border-radius:8px}canvas{width:100%;height:210px}h2{font-size:16px;margin:0 0 8px}.controls{position:sticky;top:0;background:white;padding:12px;z-index:2;border-bottom:1px solid #ccc}input{width:220px}#cursor{font-family:monospace}small{color:#485566}</style>
<header><h1>HealthApp — one-second measurements</h1><p id="status"></p><p id="window"></p><small>All panels share the same UTC timeline. Grey shading marks warmup. Missing measurements are gaps, never zero-filled. Latency is grouped by request start time; intervals with no requests have no latency value. Counter values are the plug’s absolute Wh counter.</small></header>
<div class="controls"><button onclick="location.reload()">Refresh snapshot</button> <button id="all">Include warmup</button> <button id="measured">Measured window</button> <label>From second <input id="from" type="number" min="0"></label> <label>To second <input id="to" type="number" min="1"></label><p id="cursor">Move over any graph to inspect the same second across all panels.</p></div><main id="charts"></main>
<script type="application/json" id="data">PAYLOAD_JSON</script><script>
const data=JSON.parse(document.getElementById('data').textContent),rows=data.rows,fields=data.fields,idx=Object.fromEntries(fields.map((f,i)=>[f,i]));
const panels=[['CPU (%)',['cpu_percent','cpu_iowait_percent']],['RAM (%)',['ram_percent']],['RAM / swap (MiB)',['ram_MiB','swap_MiB']],['Power (W)',['power_watts']],['Application requests / errors per second',['requests_s','errors_s']],['Application latency (ms)',['latency_mean_ms','latency_p95_ms','latency_max_ms']],['Disk / network (KiB/s)',['disk_read_KiB_s','disk_write_KiB_s','network_receive_KiB_s','network_send_KiB_s']],['Plug counter (Wh)',['energy_counter_Wh']]];
const colors=['#176bc1','#dc5a18','#379d55','#9450bd'];let lo=0,hi=rows.length-1,selected=null;
const date=t=>new Date(t).toISOString();document.getElementById('status').textContent=`${data.scenario}: ${data.status}. ${rows.length} recorded one-second intervals.`;
document.getElementById('window').textContent=`Measured window: ${date(data.timeline.measurement_start_ms)} — ${date(data.timeline.measurement_end_ms)}. All times UTC.`;
document.getElementById('measured').disabled=rows[rows.length-1][0]<data.timeline.measurement_start_ms;
const canvases=panels.map(([title,keys])=>{const s=document.createElement('section');s.innerHTML=`<h2>${title}</h2><canvas></canvas><small></small>`;document.getElementById('charts').append(s);return {canvas:s.querySelector('canvas'),legend:s.querySelector('small'),keys}});
function draw(){for(const {canvas,legend,keys} of canvases){const rect=canvas.getBoundingClientRect(),dpr=window.devicePixelRatio||1;canvas.width=rect.width*dpr;canvas.height=210*dpr;const c=canvas.getContext('2d');c.scale(dpr,dpr);const w=rect.width,h=210,left=55,right=w-15,top=12,bottom=h-32;
const x=i=>left+(right-left)*(i-lo)/Math.max(1,hi-lo);let max=1;for(let i=lo;i<=hi;i++)for(const k of keys){const v=rows[i][idx[k]];if(v!==null)max=Math.max(max,v)}max*=1.08;const y=v=>bottom-(bottom-top)*v/max;
const warmupIndex=(data.timeline.measurement_start_ms-rows[0][0])/1000;if(warmupIndex>lo){c.fillStyle='#e9ebee';c.fillRect(left,top,Math.max(0,Math.min(right,x(warmupIndex))-left),bottom-top)}
c.font='11px system-ui';for(let j=0;j<=4;j++){const yy=bottom-j*(bottom-top)/4;c.strokeStyle='#e4e7ec';c.beginPath();c.moveTo(left,yy);c.lineTo(right,yy);c.stroke();c.fillStyle='#526070';c.fillText((max*j/4).toFixed(max<10?2:0),2,yy+3)}
keys.forEach((k,n)=>{c.strokeStyle=colors[n];c.lineWidth=1.2;c.beginPath();let pen=false;for(let i=lo;i<=hi;i++){const v=rows[i][idx[k]];if(v===null){pen=false;continue}if(!pen)c.moveTo(x(i),y(v));else c.lineTo(x(i),y(v));pen=true}c.stroke()});
c.fillStyle='#526070';for(let j=0;j<=3;j++){const i=Math.round(lo+(hi-lo)*j/3);c.fillText(date(rows[i][0]).slice(11,19),Math.max(left,Math.min(right-55,x(i)-22)),h-10)}
if(selected!==null&&selected>=lo&&selected<=hi){c.strokeStyle='#182230';c.beginPath();c.moveTo(x(selected),top);c.lineTo(x(selected),bottom);c.stroke()}
legend.innerHTML=keys.map((k,n)=>`<span style="color:${colors[n]}">${k}${selected===null?'':': '+(rows[selected][idx[k]]===null?'missing':rows[selected][idx[k]].toFixed(3))}</span>`).join(' · ');
canvas.onmousemove=e=>{selected=Math.max(lo,Math.min(hi,Math.round(lo+(e.offsetX-left)/(right-left)*Math.max(1,hi-lo))));document.getElementById('cursor').textContent=`${date(rows[selected][0])} — ${rows[selected][idx.phase]}`;draw()};}}
function limits(a,b){lo=Math.max(0,Math.min(rows.length-1,a));hi=Math.max(lo,Math.min(rows.length-1,b));selected=null;document.getElementById('from').value=lo;document.getElementById('to').value=hi;draw()}
document.getElementById('all').onclick=()=>limits(0,rows.length-1);document.getElementById('measured').onclick=()=>limits(Math.floor((data.timeline.measurement_start_ms-rows[0][0])/1000),rows.length-1);
for(const id of ['from','to'])document.getElementById(id).onchange=()=>limits(Number(document.getElementById('from').value),Number(document.getElementById('to').value));window.onresize=draw;limits(0,rows.length-1);
</script></html>