summaryrefslogtreecommitdiff
path: root/benchmark/bench/render.js
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/bench/render.js')
-rw-r--r--benchmark/bench/render.js14
1 files changed, 4 insertions, 10 deletions
diff --git a/benchmark/bench/render.js b/benchmark/bench/render.js
index 449a1056f..aaeb0d022 100644
--- a/benchmark/bench/render.js
+++ b/benchmark/bench/render.js
@@ -6,14 +6,13 @@ import { execaCommand } from 'execa';
import { waitUntilBusy } from 'port-authority';
import { markdownTable } from 'markdown-table';
import { renderFiles } from '../make-project/render-default.js';
+import { calculateStat } from '../make-project/_util.js';
import { astroBin } from './_util.js';
const port = 4322;
export const defaultProject = 'render-default';
-/** @typedef {{ avg: number, stdev: number, max: number }} Stat */
-
/**
* @param {URL} projectDir
* @param {URL} outputFile
@@ -68,22 +67,17 @@ async function benchmarkRenderTime() {
result[pathname].push(renderTime);
}
}
- /** @type {Record<string, Stat>} */
+ /** @type {Record<string, import('./_util.js').Stat>} */
const processedResult = {};
for (const [pathname, times] of Object.entries(result)) {
// From the 100 results, calculate average, standard deviation, and max value
- const avg = times.reduce((a, b) => a + b, 0) / times.length;
- const stdev = Math.sqrt(
- times.map((x) => Math.pow(x - avg, 2)).reduce((a, b) => a + b, 0) / times.length
- );
- const max = Math.max(...times);
- processedResult[pathname] = { avg, stdev, max };
+ processedResult[pathname] = calculateStat(times);
}
return processedResult;
}
/**
- * @param {Record<string, Stat>} result
+ * @param {Record<string, import('./_util.js').Stat>} result
*/
function printResult(result) {
return markdownTable(