-
-
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.
- Loading branch information
Showing
62 changed files
with
1,232 additions
and
659 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Continuous benchmark | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
FORCE_COLOR: true | ||
CODSPEED_TOKEN: ${{ secrets.CODSPEED_TOKEN }} | ||
CODSPEED: true | ||
|
||
jobs: | ||
codspeed: | ||
if: ${{ github.repository_owner == 'withastro' }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PNPM | ||
uses: pnpm/action-setup@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build | ||
run: pnpm run build | ||
|
||
- name: Run the benchmarks | ||
uses: CodSpeedHQ/action@fa1dcde8d58f2ab0b407a6a24d6cc5a8c1444a8c # v3.1.0 | ||
timeout-minutes: 30 | ||
with: | ||
run: pnpm benchmark codspeed | ||
|
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,50 @@ | ||
import path from 'node:path'; | ||
import { withCodSpeed } from '@codspeed/tinybench-plugin'; | ||
import { Bench } from 'tinybench'; | ||
import { exec } from 'tinyexec'; | ||
import { renderPages } from '../make-project/render-default.js'; | ||
import { astroBin } from './_util.js'; | ||
|
||
export async function run({ memory: _memory, render, stress: _stress }) { | ||
const options = { | ||
iterations: 10, | ||
}; | ||
const bench = process.env.CODSPEED ? withCodSpeed(new Bench(options)) : new Bench(options); | ||
let app; | ||
bench.add( | ||
'Rendering', | ||
async () => { | ||
console.info('Start task.'); | ||
const result = {}; | ||
for (const fileName of renderPages) { | ||
const pathname = '/' + fileName.slice(0, -path.extname(fileName).length); | ||
const request = new Request(new URL(pathname, 'http://exmpale.com')); | ||
const response = await app.render(request); | ||
const html = await response.text(); | ||
if (!result[pathname]) result[pathname] = []; | ||
result[pathname].push(html); | ||
} | ||
console.info('Finish task.'); | ||
return result; | ||
}, | ||
{ | ||
async beforeAll() { | ||
// build for rendering | ||
await exec(astroBin, ['build'], { | ||
nodeOptions: { | ||
cwd: render.root, | ||
stdio: 'inherit', | ||
}, | ||
}); | ||
|
||
const entry = new URL('./dist/server/entry.mjs', `file://${render.root}`); | ||
const { manifest, createApp } = await import(entry); | ||
app = createApp(manifest); | ||
app.manifest = manifest; | ||
}, | ||
}, | ||
); | ||
|
||
await bench.run(); | ||
console.table(bench.table()); | ||
} |
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.