-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use
vitest
for benchmarks (#12605)
* refactor: use `vitest` for benchmarks * increase timeout * increase timeout * Restore correct label
- Loading branch information
Showing
17 changed files
with
324 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { fileURLToPath } from 'node:url'; | ||
import { exec } from 'tinyexec'; | ||
import { beforeAll, bench, describe } from 'vitest'; | ||
import { astroBin, makeProject } from './_util.js'; | ||
let streamingApp; | ||
let nonStreamingApp; | ||
beforeAll(async () => { | ||
const render = await makeProject('render-bench'); | ||
const root = fileURLToPath(render); | ||
await exec(astroBin, ['build'], { | ||
nodeOptions: { | ||
cwd: root, | ||
stdio: 'inherit', | ||
}, | ||
}); | ||
const entry = new URL('./dist/server/entry.mjs', `file://${root}`); | ||
const { manifest, createApp } = await import(entry); | ||
streamingApp = createApp(manifest, true); | ||
nonStreamingApp = createApp(manifest, false); | ||
}, 900000); | ||
|
||
describe('Bench rendering', () => { | ||
bench('Rendering: streaming [true], .astro file', async () => { | ||
const request = new Request(new URL('http://exmpale.com/astro')); | ||
await streamingApp.render(request); | ||
}); | ||
bench('Rendering: streaming [true], .md file', async () => { | ||
const request = new Request(new URL('http://exmpale.com/md')); | ||
await streamingApp.render(request); | ||
}); | ||
bench('Rendering: streaming [true], .mdx file', async () => { | ||
const request = new Request(new URL('http://exmpale.com/mdx')); | ||
await streamingApp.render(request); | ||
}); | ||
|
||
bench('Rendering: streaming [false], .astro file', async () => { | ||
const request = new Request(new URL('http://exmpale.com/astro')); | ||
await nonStreamingApp.render(request); | ||
}); | ||
bench('Rendering: streaming [false], .md file', async () => { | ||
const request = new Request(new URL('http://exmpale.com/md')); | ||
await nonStreamingApp.render(request); | ||
}); | ||
bench('Rendering: streaming [false], .mdx file', async () => { | ||
const request = new Request(new URL('http://exmpale.com/mdx')); | ||
await nonStreamingApp.render(request); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.