Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit c1a7053

Browse files
committed
chore: improve benchmark script
1 parent 3dbf660 commit c1a7053

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

compiler/benchmark.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { compile, CompileOptions } from 'https://deno.land/x/[email protected]/tsc/compile.ts'
22
import { colors, createHash, path, walk } from '../deps.ts'
3-
import { transform } from './mod.ts'
3+
import { initWasm } from './mod.ts'
4+
import { transformSync } from './dist/wasm-pack.js'
45

56
function tsc(source: string, opts: any) {
67
const compileOptions: CompileOptions = {
@@ -42,8 +43,12 @@ async function benchmark() {
4243

4344
const d1 = { d: 0, min: 0, max: 0 }
4445
const d2 = { d: 0, min: 0, max: 0 }
45-
const n = 10
46+
const n = 5
4647

48+
for (let i = 0; i < n; i++) {
49+
// v8 warm-up
50+
tsc('console.log("bla bla bla...")', { filename: '/app.ts', isDev: true })
51+
}
4752
for (const { code, filename } of sourceFiles) {
4853
const t = performance.now()
4954
for (let i = 0; i < n; i++) {
@@ -58,10 +63,15 @@ async function benchmark() {
5863
}
5964
d1.d += d
6065
}
66+
67+
for (let i = 0; i < n; i++) {
68+
// v8 warm-up
69+
transformSync('/app.ts', 'console.log("bla bla bla...")', { isDev: true })
70+
}
6171
for (const { code, filename } of sourceFiles) {
6272
const t = performance.now()
6373
for (let i = 0; i < n; i++) {
64-
transform(filename, code, {
74+
transformSync(filename, code, {
6575
swcOptions: { target: 'es2020' },
6676
isDev: true
6777
})
@@ -82,8 +92,6 @@ async function benchmark() {
8292
}
8393

8494
if (import.meta.main) {
85-
// v8 warm-up
86-
tsc('console.log("bla bla bla...")', { filename: '/app.ts', isDev: true })
87-
await transform('/app.ts', 'console.log("bla bla bla...")', { isDev: true })
95+
await initWasm()
8896
await benchmark()
8997
}

0 commit comments

Comments
 (0)