Skip to content

Commit 0a9777e

Browse files
authored
ci: shard benchmarks (#15314)
1 parent 18e0980 commit 0a9777e

7 files changed

Lines changed: 59 additions & 153 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 0 additions & 112 deletions
This file was deleted.

.github/workflows/continuous_benchmark.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ env:
2626
jobs:
2727
codspeed:
2828
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
shard: [ "1/4","2/4", "3/4", "4/4" ]
2932
permissions:
3033
contents: read
3134
pull-requests: write
@@ -58,5 +61,5 @@ jobs:
5861
timeout-minutes: 30
5962
with:
6063
working-directory: ./benchmark
61-
run: pnpm bench
64+
run: pnpm bench --shard=${{ matrix.shard }}
6265
token: ${{ secrets.CODSPEED_TOKEN }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { fileURLToPath } from 'node:url';
2+
import { build } from 'astro';
3+
import { bench, describe } from 'vitest';
4+
5+
const hybridRoot = fileURLToPath(new URL('../static-projects/build-hybrid', import.meta.url));
6+
7+
describe('Bench build time', () => {
8+
bench(
9+
'Build: hybrid site (static + server)',
10+
async () => {
11+
await build({
12+
root: hybridRoot,
13+
logLevel: 'error',
14+
});
15+
},
16+
{ timeout: 300000, iterations: 3 },
17+
);
18+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { fileURLToPath } from 'node:url';
2+
import { build } from 'astro';
3+
import { bench, describe } from 'vitest';
4+
5+
const serverRoot = fileURLToPath(new URL('../static-projects/build-server', import.meta.url));
6+
7+
describe('Bench build time', () => {
8+
bench(
9+
'Build: full server site',
10+
async () => {
11+
await build({
12+
root: serverRoot,
13+
logLevel: 'error',
14+
});
15+
},
16+
{ timeout: 300000, iterations: 3 },
17+
);
18+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { fileURLToPath } from 'node:url';
2+
import { build } from 'astro';
3+
import { bench, describe } from 'vitest';
4+
5+
const staticRoot = fileURLToPath(new URL('../static-projects/build-static', import.meta.url));
6+
7+
describe('Bench build time', () => {
8+
bench(
9+
'Build: full static site',
10+
async () => {
11+
await build({
12+
root: staticRoot,
13+
logLevel: 'error',
14+
});
15+
},
16+
{ timeout: 300000, iterations: 3 },
17+
);
18+
});
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { existsSync } from 'node:fs';
22
import { fileURLToPath } from 'node:url';
3-
import { build } from 'astro';
43
import { beforeAll, bench, describe } from 'vitest';
54

6-
const staticRoot = fileURLToPath(new URL('../static-projects/build-static', import.meta.url));
7-
const hybridRoot = fileURLToPath(new URL('../static-projects/build-hybrid', import.meta.url));
8-
const serverRoot = fileURLToPath(new URL('../static-projects/build-server', import.meta.url));
95
const renderRoot = new URL('../projects/render-bench/', import.meta.url);
106

117
let streamingApp;
@@ -51,38 +47,3 @@ describe('Bench rendering', () => {
5147
await nonStreamingApp.render(request);
5248
});
5349
});
54-
55-
describe('Bench build time', () => {
56-
bench(
57-
'Build: full static site',
58-
async () => {
59-
await build({
60-
root: staticRoot,
61-
logLevel: 'error',
62-
});
63-
},
64-
{ timeout: 300000, iterations: 3 },
65-
);
66-
67-
bench(
68-
'Build: hybrid site (static + server)',
69-
async () => {
70-
await build({
71-
root: hybridRoot,
72-
logLevel: 'error',
73-
});
74-
},
75-
{ timeout: 300000, iterations: 3 },
76-
);
77-
78-
bench(
79-
'Build: full server site',
80-
async () => {
81-
await build({
82-
root: serverRoot,
83-
logLevel: 'error',
84-
});
85-
},
86-
{ timeout: 300000, iterations: 3 },
87-
);
88-
});

benchmark/vitest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import { defineConfig } from 'vitest/config';
33

44
export default defineConfig({
55
plugins: process.env.CODSPEED ? [codspeedPlugin()] : [],
6-
include: ['./bench/codspeed.bench.js'],
6+
include: ['./bench/*.bench.js'],
77
});

0 commit comments

Comments
 (0)