-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: codspeed benchmark #12347
Merged
Merged
chore: codspeed benchmark #12347
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
889f98c
chore: codspeed benchmark
ematipico a62ac1b
feat: benchmarking with codespeed
ematipico bfb3023
fix job
ematipico 9fdcc0f
ooops
ematipico ccb884f
address feedback
ematipico ef3b496
revert
ematipico 1906c72
fix error during benching
ematipico 30f5645
revert
ematipico 1c98d84
reduce projects for now
ematipico fca6ecd
more timeout?
ematipico 1ad10df
chore: use adapter to run renderings
ematipico cab3ffb
less samples because CI is slower
ematipico bd7579a
less samples because CI is slower
ematipico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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@b587655f756aab640e742fec141261bc6f0a569d # v3.0.1 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,6 @@ function printResult(output) { | |
], | ||
{ | ||
align: ['l', 'r', 'r', 'r'], | ||
} | ||
}, | ||
); | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable wasn't used