Skip to content

Commit

Permalink
Support single benchmark results
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Sep 15, 2020
1 parent 92fc3e1 commit e5c0294
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 2 deletions.
7 changes: 6 additions & 1 deletion dist/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14769,7 +14769,12 @@ function buildReport(
let bench = benchmarks[benchIndex];
resultsByMeasurement.get(measurementId).push({
...bench,
differences: pickArray(bench.differences, benchIndexes),

// Results of a single benchmark may not have the differences array
// defined. Leave it as is in that case.
differences: bench.differences
? pickArray(bench.differences, benchIndexes)
: bench.differences,
});
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ function buildReport(
let bench = benchmarks[benchIndex];
resultsByMeasurement.get(measurementId).push({
...bench,
differences: pickArray(bench.differences, benchIndexes),

// Results of a single benchmark may not have the differences array
// defined. Leave it as is in that case.
differences: bench.differences
? pickArray(bench.differences, benchIndexes)
: bench.differences,
});
}
}
Expand Down
68 changes: 68 additions & 0 deletions tests/fixtures/single-results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<div>
<h2>📊 Tachometer Benchmark Results</h2>
<h3>Summary</h3>
<p class="global-status"></p>
<div id="tachometer-reporter-action--summaries">
<div data-sort-key="000-default">
<ul
id="tachometer-reporter-action--summaries::vLpvdPi0hOozeUB9NMaWIJ9oUSA"
>
<li data-sort-key="test_bench">
<div
id="tachometer-reporter-action--summary::vLpvdPi0hOozeUB9NMaWIJ9oUSA::fEj_fzhw6EB17web7iBi6ijgNvI"
class="summary::fEj_fzhw6EB17web7iBi6ijgNvI"
data-run-number="50"
>
<span class="status"></span>test_bench: 32.09ms - 38.19ms
</div>
</li>
</ul>
</div>
</div>
<h3>Results</h3>
<p class="global-status"></p>
<div id="tachometer-reporter-action--results">
<div
id="tachometer-reporter-action--results-fEj_fzhw6EB17web7iBi6ijgNvI"
data-run-number="50"
data-sort-key="test_bench"
>
<details
><summary
><span class="status"></span><strong>test_bench</strong></summary
>
<div class="result-entry">
<ul>
<li>Browser: chrome-headless 83.0.4103.116</li>
<li>Sample size: 60</li>
<li>
Built by:
<a
href="https://github.com/andrewiggins/tachometer-reporter-action/runs/862215228"
>Pull Request Test #50</a
>
</li>
<li>
Commit: 626e78c
</li>
</ul>
<table class="results::vLpvdPi0hOozeUB9NMaWIJ9oUSA">
<thead>
<tr>
<th>Version</th>
<th>Avg time</th>
<th>vs</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center"></td>
<td align="center">32.09ms - 38.19ms</td>
<td align="center"></td>
</tr>
</tbody>
</table></div
></details>
</div>
</div>
</div>
18 changes: 18 additions & 0 deletions tests/getCommentBody.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,24 @@ newCommentSuite(
}
);

newCommentSuite("Renders expected body for single results", async () => {
const results = JSON.parse(
await readFile(testRoot("results/single-results.json"), "utf8")
);

const report = invokeBuildReport({ results });
const body = invokeGetCommentBody({ report });
const html = formatHtml(body.toString());

const fixturePath = testRoot("fixtures/single-results.html");
const fixture = await readFile(fixturePath, "utf-8");

// Uncomment to update fixture
// await writeFile(fixturePath, html, "utf8");

assertFixture(html, fixture, "Report body matches fixture");
});

//#endregion

//#region Update Comment Suite
Expand Down
84 changes: 84 additions & 0 deletions tests/results/single-results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"benchmarks": [
{
"name": "test_bench",
"bytesSent": 75584,
"version": "fast-framework",
"browser": {
"name": "chrome",
"headless": true,
"windowSize": {
"width": 1024,
"height": 768
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/83.0.4103.116 Safari/537.36"
},
"mean": {
"low": 32.09199918627131,
"high": 38.18983410757643
},
"samples": [
27.294999919831753,
25.790000101551414,
53.36000001989305,
25.215000146999955,
27.1399999037385,
24.865000043064356,
28.960000025108457,
26.455000042915344,
26.704999851062894,
27.144999941810966,
25.0600001309067,
45.374999986961484,
62.26999987848103,
27.700000209733844,
27.920000022277236,
32.700000097975135,
27.289999881759286,
28.15499994903803,
27.53999992273748,
24.264999898150563,
26.784999994561076,
27.654999867081642,
28.584999963641167,
31.84000006876886,
26.805000146850944,
30.030000023543835,
26.455000042915344,
26.765000075101852,
49.55999995581806,
61.88499997369945,
45.05000007338822,
33.91999984160066,
35.07999982684851,
30.544999986886978,
26.649999897927046,
26.969999773427844,
25.569999823346734,
25.65499977208674,
28.92000018619001,
27.974999975413084,
33.59999996609986,
62.774999998509884,
57.459999807178974,
43.415000196546316,
61.12500000745058,
42.78999986127019,
44.84999994747341,
55.85499992594123,
37.92999987490475,
48.264999873936176,
49.81500003486872,
59.85999992117286,
44.11500017158687,
32.630000030621886,
28.26500008814037,
33.46499986946583,
28.110000072047114,
24.304999969899654,
27.624999871477485,
28.295000083744526
]
}
]
}

0 comments on commit e5c0294

Please sign in to comment.