Skip to content

Commit b363bef

Browse files
fulloclaude
andcommitted
Fix delta comparison: only compare entries of the same script
Both HtmlReporter and TrendReporter were comparing each entry's SCI to the chronologically previous entry regardless of which script it belonged to. This produced misleading ▲ worse arrows when transitioning between different scripts (e.g., string→database). Fix: track last SCI per script_filename. Delta is only shown when the same script has a previous measurement to compare against. Before: database iter1 showed ▲ worse (vs string iter3 — wrong script) After: database iter1 shows no delta (first measurement of this script) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 28ad6da commit b363bef

7 files changed

Lines changed: 63 additions & 57 deletions

File tree

bin/sci-profiler.phar

486 Bytes
Binary file not shown.

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:13:51+00:00</p>
44+
<p class="meta">Machine: SCI Profiler examples | Generated: 2026-03-19T00:16:26+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.21745733333333</div>
53+
<div class="value">0.21762355555556</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.957116</div>
58+
<div class="value">1.958612</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.562888888889</div>
63+
<div class="value">32.587777777778</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,95.7 151.2,100.2 242.5,105.8 333.8,20.0 425.0,83.3 516.2,130.0 607.5,24.7 698.8,81.5 790.0,98.8 790.0,130.0 60.0,130.0" fill="rgba(45,106,79,0.1)" /><polyline points="60.0,95.7 151.2,100.2 242.5,105.8 333.8,20.0 425.0,83.3 516.2,130.0 607.5,24.7 698.8,81.5 790.0,98.8" 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.4905</text><text x="55" y="134.0" font-size="10" fill="#888" text-anchor="end">0.0079</text><text x="60" y="148" font-size="9" fill="#aaa">2026-03-19T00:13</text><text x="790" y="148" font-size="9" fill="#aaa" text-anchor="end">2026-03-19T00:13</text></svg></div>
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>
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.1370</td><td class="num">20.52</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,10.9 120.0,22.0" fill="none" stroke="#2d6a4f" stroke-width="1.5" stroke-linejoin="round" /></svg></td><td><span class="lastprev">0.1386 → 0.1140 <span class="arrow" style="color:#28a745">▼ -17.8%</span></span></td><td></td></tr><tr><td>examples/02-database-simulation.php</td><td class="num">3</td><td class="num">0.2370</td><td class="num">35.49</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.5 120.0,22.0" fill="none" stroke="#2d6a4f" stroke-width="1.5" stroke-linejoin="round" /></svg></td><td><span class="lastprev">0.2126 → 0.0079 <span class="arrow" style="color:#28a745">▼ -96.3%</span></span></td><td></td></tr><tr><td>examples/03-json-api.php</td><td class="num">3</td><td class="num">0.2783</td><td class="num">41.68</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.2206 → 0.1446 <span class="arrow" style="color:#28a745">▼ -34.4%</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.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>
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:13:51</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">21.66</td><td class="num">0.1446 <span class="delta better"></span></td><td class="num">22.47</td></tr><tr><td>2026-03-19T00:13:50</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">33.03</td><td class="num">0.2206 <span class="delta better"></span></td><td class="num">30.47</td></tr><tr><td>2026-03-19T00:13:49</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/03-json-api.php</td><td class="num">70.34</td><td class="num">0.4698 <span class="delta worse"></span></td><td class="num">48.94</td></tr><tr><td>2026-03-19T00:13:49</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">1.18</td><td class="num">0.0079 <span class="delta better"></span></td><td class="num">4</td></tr><tr><td>2026-03-19T00:13:48</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">31.84</td><td class="num">0.2126 <span class="delta better"></span></td><td class="num">4</td></tr><tr><td>2026-03-19T00:13:47</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/02-database-simulation.php</td><td class="num">73.45</td><td class="num">0.4905 <span class="delta worse"></span></td><td class="num">4</td></tr><tr><td>2026-03-19T00:13:46</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">17.07</td><td class="num">0.1140 <span class="delta better"></span></td><td class="num">18</td></tr><tr><td>2026-03-19T00:13:45</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">20.76</td><td class="num">0.1386 <span class="delta better"></span></td><td class="num">18</td></tr><tr><td>2026-03-19T00:13:44</td><td>CLI</td><td>/Users/fullo/Development/sci-profiler-php/examples/01-string-processing.php</td><td class="num">23.73</td><td class="num">0.1585</td><td class="num">16</td></tr></tbody>
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>
102102
</table>
103103
</body>
104104
</html>

0 commit comments

Comments
 (0)