From 743674a022728becd43740a1dcdb7c2131996509 Mon Sep 17 00:00:00 2001 From: Steffen Date: Thu, 8 Oct 2026 12:59:43 +0200 Subject: [PATCH] Report aligned per-second CPU power requests latency and errors --- tools/energy-jmeter/README.md | 35 ++++++++ tools/energy-jmeter/report-template.html | 25 ++++++ tools/energy-jmeter/report.py | 109 +++++++++++++++++++++++ tools/energy-jmeter/run.py | 7 ++ tools/energy-jmeter/verify-report.py | 25 ++++++ 5 files changed, 201 insertions(+) create mode 100644 tools/energy-jmeter/report-template.html create mode 100644 tools/energy-jmeter/report.py create mode 100644 tools/energy-jmeter/verify-report.py diff --git a/tools/energy-jmeter/README.md b/tools/energy-jmeter/README.md index b73faad..22d98c8 100644 --- a/tools/energy-jmeter/README.md +++ b/tools/energy-jmeter/README.md @@ -284,3 +284,38 @@ python3 tools/energy-jmeter/verify-perfmon.py --host 192.168.1.125 --output tool This verifies that JMeter saves readings while it is still running, then checks metric coverage and decoding. A monitoring-only check succeeded against the NUC; comparison with independent Linux readings is still needed to validate accuracy. + +## Time-aligned graphs and one-second request reporting + +Every finished run generates `report.html` (interactive), `report.png`, `report.svg` +and `per-second.csv`. The plotting dependency is Matplotlib, already installed on +this computer. If setting up another load generator, install Matplotlib there. +All panels share UTC timestamps and experiment-relative one-second intervals, +starting at the recorded warmup start. Warmup is shaded; measurement begins after +the exact configured warmup duration. + +CPU, RAM, power, disk and network values are averaged only when multiple samples +fall into a second; missing readings stay blank and create graph gaps. Application +requests and failed requests are counted individually per second. Mean/p95/max +latency is grouped by request start time, with p95 using the nearest-rank definition. +Requests spanning the measurement end are excluded from measured application figures, +matching `run.json`. Meter requests and internal timing samples never count as +application traffic. Seconds without requests have zero request/error counts and +no response-time value. The graph keeps every one-second bin; a wide full-run view +can visually compress points. Use the interactive range controls to inspect seconds. + +For a running experiment, generate a snapshot or keep refreshing its artifacts: + +```bash +python3 tools/energy-jmeter/report.py tools/energy-jmeter/results/RUN_FOLDER +python3 tools/energy-jmeter/report.py tools/energy-jmeter/results/RUN_FOLDER --follow +``` + +`--follow` refreshes artifacts every minute, using one-second data, and generates the +final report when the run finishes. Open `report.html` locally and use **Refresh +snapshot** to load new data. It provides a shared cursor across panels and a measured- +window selection. The latest seconds of a running snapshot are provisional because +JMeter writes request samples after their responses arrive. Missing future seconds +are not plotted as zeros. Report creation runs on the load generator. + +Verify aggregation with `python3 tools/energy-jmeter/verify-report.py`. diff --git a/tools/energy-jmeter/report-template.html b/tools/energy-jmeter/report-template.html new file mode 100644 index 0000000..38a5b53 --- /dev/null +++ b/tools/energy-jmeter/report-template.html @@ -0,0 +1,25 @@ +HealthApp measurement report + +

HealthApp — one-second measurements

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.
+

Move over any graph to inspect the same second across all panels.

+ diff --git a/tools/energy-jmeter/report.py b/tools/energy-jmeter/report.py new file mode 100644 index 0000000..6a3e0ad --- /dev/null +++ b/tools/energy-jmeter/report.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python3 +"""Align raw JMeter measurements into experiment-relative one-second bins.""" +import os,time +import argparse,csv,datetime as dt,json,math +from pathlib import Path +FIELDS=['timestamp_ms','phase','cpu_percent','cpu_iowait_percent','ram_percent','ram_MiB','swap_MiB','power_watts','energy_counter_Wh','disk_read_KiB_s','disk_write_KiB_s','network_receive_KiB_s','network_send_KiB_s','requests_s','errors_s','error_percent','latency_mean_ms','latency_p95_ms','latency_max_ms','power_poll_errors_s'] +METRIC_FIELDS={'CPU combined':('cpu_percent',1),'CPU iowait':('cpu_iowait_percent',1),'Memory usedperc':('ram_percent',1),'Memory actualused':('ram_MiB',1/1048576),'Swap used':('swap_MiB',1/1048576),'Disks I/O readbytes':('disk_read_KiB_s',1/1024),'Disks I/O writebytes':('disk_write_KiB_s',1/1024),'Network I/O bytesrecv':('network_receive_KiB_s',1/1024),'Network I/O bytessent':('network_send_KiB_s',1/1024)} +def read_csv(path): + if not path.exists():return [] + with path.open(newline='') as f: + # Autoflush can expose the final line during a write; ignore incomplete rows. + return [r for r in csv.DictReader(f) if r and None not in r and all(v is not None for v in r.values())] +def finished(meta): + return ('finished_utc' in meta + and (not meta.get('perfmon',{}).get('enabled') or 'server_metrics' in meta or 'monitoring_error' in meta) + and (not meta.get('shelly',{}).get('enabled') or 'power_energy' in meta or 'power_error' in meta)) +def build(folder): + folder=Path(folder);meta=json.loads((folder/'run.json').read_text());timeline=json.loads((folder/'timeline.json').read_text()) + start=timeline['warmup_start_ms'];measurement_start=timeline['measurement_start_ms'];end=timeline['measurement_end_ms'] + bins={};latest=start;bad_rows=0 + def bucket(timestamp): + nonlocal latest + if not start<=timestamp=measurement_start and float(r['timeStamp'])+float(r['elapsed'])>end:continue + row['requests_s']+=1;row['errors_s']+=r['success'].lower()!='true';row['latencies'].append(float(r['elapsed'])) + except (ValueError,KeyError,TypeError):bad_rows+=1 + completed=finished(meta) + if completed: + finish=int(dt.datetime.fromisoformat(meta['finished_utc']).timestamp()*1000) + observed_end=min(end,finish) + else:observed_end=min(end,int(latest)+1) + count=max(1,math.ceil((observed_end-start)/1000));rows=[] + for index in range(count): + timestamp=start+index*1000;source=bins.get(index,{'averages':{},'latencies':[],'requests_s':0,'errors_s':0,'power_poll_errors_s':0}) + row={field:None for field in FIELDS};row.update(timestamp_ms=timestamp,phase='warmup' if timestamp