Skip to content

Commit 1b55a20

Browse files
fulloclaude
andcommitted
Timeline chart: one line per script, per-script delta comparison
SVG timeline chart now renders a separate colored polyline for each script instead of a single mixed line. Each script gets its own color with a legend at the bottom. Scripts with only 1 entry are excluded. Detail table delta marks now only compare entries of the same script — transitioning between different scripts no longer shows misleading ▲ worse arrows. New tests (123 total, 577 assertions): - testTimelineShowsSeparateLinePerScript: 2 polylines for 2 scripts - testTimelineSkipsScriptWithSingleEntry: only multi-entry scripts drawn - testDeltaOnlyComparesSameScript: interleaved scripts get correct deltas - testNoDeltaOnFirstEntryOfNewScript: first entry of new script = no delta Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b363bef commit 1b55a20

8 files changed

Lines changed: 234 additions & 102 deletions

File tree

bin/sci-profiler.phar

1.43 KB
Binary file not shown.

doc/reporters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ Best for: visual overview, team dashboards, periodic review.
113113
### What it shows
114114

115115
- **Summary cards**: total requests, average SCI, total emissions, average response time
116-
- **SVG timeline chart**: inline SVG polyline of SCI values over the last 50 entries, with area fill, grid lines, and axis labels — no JavaScript required
116+
- **SVG timeline chart**: one colored polyline per script showing SCI trajectory over time, with a shared Y-axis, grid lines, and legend — no JavaScript required. Scripts with a single entry are excluded from the chart.
117117
- **Per-script summary table**: grouped by script filename, with inline SVG sparkline, "last vs previous" comparison (with percentage delta), and first-half/second-half trend indicator
118118
- **Measurement parameters**: device power (E), grid carbon intensity (I), embodied carbon (M), device lifetime
119-
- **Detail table**: timestamp, method, URI (with script filename), response time, SCI score with delta marks (▲/▼), status badges (200/301/500), peak memory — last 200 requests
119+
- **Detail table**: timestamp, method, URI (with script filename), response time, SCI score with per-script delta marks (▲/▼ — only comparing entries of the same script), status badges (200/301/500), peak memory — last 200 requests
120120

121121
### Setup
122122

examples/results/dashboard.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</head>
4242
<body>
4343
<h1>SCI Profiler Dashboard</h1>
44-
<p class="meta">Machine: SCI Profiler examples | Generated: 2026-03-19T00:16:26+00:00</p>
44+
<p class="meta">Machine: SCI Profiler examples | Generated: 2026-03-19T00:20:25+00:00</p>
4545

4646
<div class="cards">
4747
<div class="card">
@@ -50,22 +50,22 @@ <h1>SCI Profiler Dashboard</h1>
5050
</div>
5151
<div class="card">
5252
<div class="label">Avg SCI Score</div>
53-
<div class="value">0.21762355555556</div>
53+
<div class="value">0.21870633333333</div>
5454
<div class="unit">mgCO2eq / request</div>
5555
</div>
5656
<div class="card">
5757
<div class="label">Total Emissions</div>
58-
<div class="value">1.958612</div>
58+
<div class="value">1.968357</div>
5959
<div class="unit">mgCO2eq</div>
6060
</div>
6161
<div class="card">
6262
<div class="label">Avg Response Time</div>
63-
<div class="value">32.587777777778</div>
63+
<div class="value">32.749888888889</div>
6464
<div class="unit">ms</div>
6565
</div>
6666
</div>
6767

68-
<h2>SCI Timeline (Last 9)</h2><div class="timeline-box"><svg viewBox="0 0 800 150" xmlns="http://www.w3.org/2000/svg"><line x1="60" y1="102.5" x2="790" y2="102.5" stroke="#eee" stroke-width="1"/><line x1="60" y1="75.0" x2="790" y2="75.0" stroke="#eee" stroke-width="1"/><line x1="60" y1="47.5" x2="790" y2="47.5" stroke="#eee" stroke-width="1"/><polygon points="60.0,93.2 151.2,97.7 242.5,107.4 333.8,20.6 425.0,82.5 516.2,130.0 607.5,20.0 698.8,78.4 790.0,96.5 790.0,130.0 60.0,130.0" fill="rgba(45,106,79,0.1)" /><polyline points="60.0,93.2 151.2,97.7 242.5,107.4 333.8,20.6 425.0,82.5 516.2,130.0 607.5,20.0 698.8,78.4 790.0,96.5" fill="none" stroke="#2d6a4f" stroke-width="2" stroke-linejoin="round" /><text x="55" y="24.0" font-size="10" fill="#888" text-anchor="end">0.4761</text><text x="55" y="134.0" font-size="10" fill="#888" text-anchor="end">0.0076</text><text x="60" y="148" font-size="9" fill="#aaa">2026-03-19T00:16</text><text x="790" y="148" font-size="9" fill="#aaa" text-anchor="end">2026-03-19T00:16</text></svg></div>
68+
<h2>SCI Timeline (9 entries)</h2><div class="timeline-box"><svg viewBox="0 0 800 180" xmlns="http://www.w3.org/2000/svg"><line x1="60" y1="110.0" x2="790" y2="110.0" stroke="#eee" stroke-width="1"/><line x1="60" y1="80.0" x2="790" y2="80.0" stroke="#eee" stroke-width="1"/><line x1="60" y1="50.0" x2="790" y2="50.0" stroke="#eee" stroke-width="1"/><text x="55" y="24.0" font-size="10" fill="#888" text-anchor="end">0.4755</text><text x="55" y="144.0" font-size="10" fill="#888" text-anchor="end">0.0103</text><polyline points="60.0,100.8 425.0,108.5 790.0,114.0" fill="none" stroke="#2d6a4f" stroke-width="2" stroke-linejoin="round" /><circle cx="790.0" cy="114.0" r="3" fill="#2d6a4f" /><polyline points="60.0,20.5 425.0,88.7 790.0,140.0" fill="none" stroke="#d62828" stroke-width="2" stroke-linejoin="round" /><circle cx="790.0" cy="140.0" r="3" fill="#d62828" /><polyline points="60.0,20.0 425.0,82.8 790.0,100.8" fill="none" stroke="#457b9d" stroke-width="2" stroke-linejoin="round" /><circle cx="790.0" cy="100.8" r="3" fill="#457b9d" /><rect x="60" y="162" width="12" height="3" fill="#2d6a4f" /><text x="76" y="165" font-size="9" fill="#555">examples/01-string-processing.php</text><rect x="272" y="162" width="12" height="3" fill="#d62828" /><text x="288" y="165" font-size="9" fill="#555">examples/02-database-simulation.php</text><rect x="494" y="162" width="12" height="3" fill="#457b9d" /><text x="510" y="165" font-size="9" fill="#555">examples/03-json-api.php</text></svg></div>
6969

7070
<h2>Measurement Parameters</h2><div class="config-grid"><div class="config-item"><div class="ck">Device Power (E)</div><div class="cv">18 W</div></div><div class="config-item"><div class="ck">Grid Carbon Intensity (I)</div><div class="cv">332 gCO2eq/kWh</div></div><div class="config-item"><div class="ck">Embodied Carbon (M)</div><div class="cv">211,000 gCO2eq</div></div><div class="config-item"><div class="ck">Device Lifetime</div><div class="cv">11,680 hours</div></div></div>
7171

@@ -83,7 +83,7 @@ <h2>Per-Script Summary</h2>
8383
<th>Trend</th>
8484
</tr>
8585
</thead>
86-
<tbody><tr><td>examples/01-string-processing.php</td><td class="num">3</td><td class="num">0.1379</td><td class="num">20.65</td><td class="num">18.0</td><td><svg class="sparkline" width="120" height="24" viewBox="0 0 120 24"><polyline points="0.0,2.0 60.0,8.3 120.0,22.0" fill="none" stroke="#2d6a4f" stroke-width="1.5" stroke-linejoin="round" /></svg></td><td><span class="lastprev">0.1453 → 0.1039 <span class="arrow" style="color:#28a745">▼ -28.5%</span></span></td><td></td></tr><tr><td>examples/02-database-simulation.php</td><td class="num">3</td><td class="num">0.2303</td><td class="num">34.48</td><td class="num">4.0</td><td><svg class="sparkline" width="120" height="24" viewBox="0 0 120 24"><polyline points="0.0,2.0 60.0,13.3 120.0,22.0" fill="none" stroke="#2d6a4f" stroke-width="1.5" stroke-linejoin="round" /></svg></td><td><span class="lastprev">0.2098 → 0.0076 <span class="arrow" style="color:#28a745">▼ -96.4%</span></span></td><td></td></tr><tr><td>examples/03-json-api.php</td><td class="num">3</td><td class="num">0.2847</td><td class="num">42.63</td><td class="num">48.9</td><td><svg class="sparkline" width="120" height="24" viewBox="0 0 120 24"><polyline points="0.0,2.0 60.0,17.3 120.0,22.0" fill="none" stroke="#2d6a4f" stroke-width="1.5" stroke-linejoin="round" /></svg></td><td><span class="lastprev">0.2275 → 0.1505 <span class="arrow" style="color:#28a745">▼ -33.8%</span></span></td><td></td></tr></tbody>
86+
<tbody><tr><td>examples/01-string-processing.php</td><td class="num">3</td><td class="num">0.1352</td><td class="num">20.24</td><td class="num">18.0</td><td><svg class="sparkline" width="120" height="24" viewBox="0 0 120 24"><polyline points="0.0,2.0 60.0,13.6 120.0,22.0" fill="none" stroke="#2d6a4f" stroke-width="1.5" stroke-linejoin="round" /></svg></td><td><span class="lastprev">0.1324 → 0.1110 <span class="arrow" style="color:#28a745">▼ -16.2%</span></span></td><td></td></tr><tr><td>examples/02-database-simulation.php</td><td class="num">3</td><td class="num">0.2309</td><td class="num">34.58</td><td class="num">4.0</td><td><svg class="sparkline" width="120" height="24" viewBox="0 0 120 24"><polyline points="0.0,2.0 60.0,13.4 120.0,22.0" fill="none" stroke="#2d6a4f" stroke-width="1.5" stroke-linejoin="round" /></svg></td><td><span class="lastprev">0.2090 → 0.0103 <span class="arrow" style="color:#28a745">▼ -95.1%</span></span></td><td></td></tr><tr><td>examples/03-json-api.php</td><td class="num">3</td><td class="num">0.2900</td><td class="num">43.43</td><td class="num">48.9</td><td><svg class="sparkline" width="120" height="24" viewBox="0 0 120 24"><polyline points="0.0,2.0 60.0,17.5 120.0,22.0" fill="none" stroke="#2d6a4f" stroke-width="1.5" stroke-linejoin="round" /></svg></td><td><span class="lastprev">0.2322 → 0.1624 <span class="arrow" style="color:#28a745">▼ -30.1%</span></span></td><td></td></tr></tbody>
8787
</table>
8888

8989
<h2>Recent Requests</h2>
@@ -98,7 +98,7 @@ <h2>Recent Requests</h2>
9898
<th>Peak (MB)</th>
9999
</tr>
100100
</thead>
101-
<tbody><tr><td>2026-03-19T00:16:26</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">22.54</td><td class="num">0.1505 <span class="delta better"></span></td><td class="num">22.47</td></tr><tr><td>2026-03-19T00:16:25</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">34.06</td><td class="num">0.2275 <span class="delta better"></span></td><td class="num">30.47</td></tr><tr><td>2026-03-19T00:16:24</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">71.30</td><td class="num">0.4761</td><td class="num">48.94</td></tr><tr><td>2026-03-19T00:16:24</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">1.15</td><td class="num">0.0076 <span class="delta better"></span></td><td class="num">4</td></tr><tr><td>2026-03-19T00:16:23</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">31.42</td><td class="num">0.2098 <span class="delta better"></span></td><td class="num">4</td></tr><tr><td>2026-03-19T00:16:21</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">70.89</td><td class="num">0.4734</td><td class="num">4</td></tr><tr><td>2026-03-19T00:16:21</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">15.55</td><td class="num">0.1039 <span class="delta better"></span></td><td class="num">18</td></tr><tr><td>2026-03-19T00:16:20</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">21.75</td><td class="num">0.1453 <span class="delta better"></span></td><td class="num">18</td></tr><tr><td>2026-03-19T00:16:19</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">24.63</td><td class="num">0.1645</td><td class="num">16</td></tr></tbody>
101+
<tbody><tr><td>2026-03-19T00:20:25</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">24.32</td><td class="num">0.1624 <span class="delta better"></span></td><td class="num">22.47</td></tr><tr><td>2026-03-19T00:20:24</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">34.77</td><td class="num">0.2322 <span class="delta better"></span></td><td class="num">30.47</td></tr><tr><td>2026-03-19T00:20:23</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">71.20</td><td class="num">0.4755</td><td class="num">48.94</td></tr><tr><td>2026-03-19T00:20:23</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">1.54</td><td class="num">0.0103 <span class="delta better"></span></td><td class="num">4</td></tr><tr><td>2026-03-19T00:20:22</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">31.29</td><td class="num">0.2090 <span class="delta better"></span></td><td class="num">4</td></tr><tr><td>2026-03-19T00:20:21</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">70.90</td><td class="num">0.4735</td><td class="num">4</td></tr><tr><td>2026-03-19T00:20:20</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">16.62</td><td class="num">0.1110 <span class="delta better"></span></td><td class="num">18</td></tr><tr><td>2026-03-19T00:20:19</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">19.83</td><td class="num">0.1324 <span class="delta better"></span></td><td class="num">18</td></tr><tr><td>2026-03-19T00:20:18</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">24.27</td><td class="num">0.1621</td><td class="num">16</td></tr></tbody>
102102
</table>
103103
</body>
104104
</html>

0 commit comments

Comments
 (0)