diff options
author | 2024-11-06 23:17:39 +0800 | |
---|---|---|
committer | 2024-11-06 23:17:39 +0800 | |
commit | 7db86cf2b75c547b5947bc1a10f21d2e3e56e9da (patch) | |
tree | 115d93a2565958a069462d4e39446059e6395339 /benchmark/bench/render.js | |
parent | c280655655cc6c22121f32c5f7c76836adf17230 (diff) | |
parent | e10b03e88c22592fbb42d7245b65c4f486ab736d (diff) | |
download | astro-7db86cf2b75c547b5947bc1a10f21d2e3e56e9da.tar.gz astro-7db86cf2b75c547b5947bc1a10f21d2e3e56e9da.tar.zst astro-7db86cf2b75c547b5947bc1a10f21d2e3e56e9da.zip |
Merge branch 'main' into next
Diffstat (limited to 'benchmark/bench/render.js')
-rw-r--r-- | benchmark/bench/render.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/benchmark/bench/render.js b/benchmark/bench/render.js index aee04f2b5..02f75a73b 100644 --- a/benchmark/bench/render.js +++ b/benchmark/bench/render.js @@ -1,12 +1,12 @@ -import { exec } from 'tinyexec'; -import { markdownTable } from 'markdown-table'; import fs from 'node:fs/promises'; import http from 'node:http'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; +import { markdownTable } from 'markdown-table'; import { waitUntilBusy } from 'port-authority'; -import { calculateStat, astroBin } from './_util.js'; +import { exec } from 'tinyexec'; import { renderPages } from '../make-project/render-default.js'; +import { astroBin, calculateStat } from './_util.js'; const port = 4322; @@ -25,6 +25,7 @@ export async function run(projectDir, outputFile) { cwd: root, stdio: 'inherit', }, + throwOnError: true, }); console.log('Previewing...'); @@ -33,6 +34,7 @@ export async function run(projectDir, outputFile) { cwd: root, stdio: 'inherit', }, + throwOnError: true, }); console.log('Waiting for server ready...'); @@ -58,14 +60,14 @@ export async function run(projectDir, outputFile) { console.log('Done!'); } -async function benchmarkRenderTime() { +export async function benchmarkRenderTime(portToListen = port) { /** @type {Record<string, number[]>} */ const result = {}; for (const fileName of renderPages) { // Render each file 100 times and push to an array for (let i = 0; i < 100; i++) { const pathname = '/' + fileName.slice(0, -path.extname(fileName).length); - const renderTime = await fetchRenderTime(`http://localhost:${port}${pathname}`); + const renderTime = await fetchRenderTime(`http://localhost:${portToListen}${pathname}`); if (!result[pathname]) result[pathname] = []; result[pathname].push(renderTime); } @@ -95,7 +97,7 @@ function printResult(result) { ], { align: ['l', 'r', 'r', 'r'], - } + }, ); } |