Skip to content

Commit edd5829

Browse files
committed
refactor: k6 must be js
1 parent 782b82f commit edd5829

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

.github/workflows/benchmark.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Run
3434
run: yarn tsx benchmark/servers/http.ts &
3535
- name: Benchmark
36-
run: ./k6 run benchmark/k6.ts --summary-export summary.json
36+
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
3737
- name: Summary
3838
run: |
3939
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -59,7 +59,7 @@ jobs:
5959
- name: Run
6060
run: yarn tsx benchmark/servers/express.ts &
6161
- name: Benchmark
62-
run: ./k6 run benchmark/k6.ts --summary-export summary.json
62+
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
6363
- name: Summary
6464
run: |
6565
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -85,7 +85,7 @@ jobs:
8585
- name: Run
8686
run: yarn tsx benchmark/servers/fastify.ts &
8787
- name: Benchmark
88-
run: ./k6 run benchmark/k6.ts --summary-export summary.json
88+
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
8989
- name: Summary
9090
run: |
9191
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -111,7 +111,7 @@ jobs:
111111
- name: Run
112112
run: yarn tsx benchmark/servers/koa.ts &
113113
- name: Benchmark
114-
run: ./k6 run benchmark/k6.ts --summary-export summary.json
114+
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
115115
- name: Summary
116116
run: |
117117
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -137,7 +137,7 @@ jobs:
137137
- name: Run
138138
run: yarn tsx benchmark/servers/uWebSockets.ts &
139139
- name: Benchmark
140-
run: ./k6 run benchmark/k6.ts --summary-export summary.json
140+
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
141141
- name: Summary
142142
run: |
143143
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -171,7 +171,7 @@ jobs:
171171
- name: Run
172172
run: deno run -A benchmark/servers/deno.ts &
173173
- name: Benchmark
174-
run: ./k6 run benchmark/k6.ts --summary-export summary.json
174+
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
175175
- name: Summary
176176
run: |
177177
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -201,7 +201,7 @@ jobs:
201201
- name: Run
202202
run: bun run benchmark/servers/bun.ts &
203203
- name: Benchmark
204-
run: ./k6 run benchmark/k6.ts --summary-export summary.json
204+
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
205205
- name: Summary
206206
run: |
207207
echo '```json' >> $GITHUB_STEP_SUMMARY

benchmark/k6.ts renamed to benchmark/k6.mjs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { check, fail } from 'k6';
2-
import { Options } from 'k6/options';
32
import { Counter, Trend } from 'k6/metrics';
4-
import http, { RefinedResponse } from 'k6/http';
3+
import http from 'k6/http';
54

65
const port = parseInt(__ENV.PORT || '');
76
if (isNaN(port)) {
87
throw new Error('Missing PORT environment variable!');
98
}
109

11-
export const options: Options = {
10+
/** @type {import("k6/options").Options} */
11+
export const options = {
1212
scenarios: {
1313
get: {
1414
executor: 'constant-vus',
@@ -27,10 +27,8 @@ export const options: Options = {
2727
},
2828
};
2929

30-
const scenarioMetrics: Record<
31-
string,
32-
{ runs: Counter; oks: Counter; duration: Trend }
33-
> = {};
30+
/** @type {Record<string, { runs: Counter, oks: Counter, duration: Trend }>} */
31+
const scenarioMetrics = {};
3432
for (const scenario of Object.keys(options.scenarios || {})) {
3533
scenarioMetrics[scenario] = {
3634
runs: new Counter(`query_runs(${scenario})`),
@@ -49,7 +47,8 @@ export default function () {
4947
const begin = Date.now();
5048
metrics.runs.add(1);
5149

52-
let res: RefinedResponse<'text'>;
50+
/** @type {import("k6/http").RefinedResponse<'text'>} */
51+
let res;
5352
switch (scenario) {
5453
case 'get':
5554
res = http.get(`http://localhost:${port}/graphql?query={hello}`);

0 commit comments

Comments
 (0)