Skip to content

Commit 347f8be

Browse files
authored
bench: add TypeScript (#9)
``` ❯ pnpm bench > [email protected] bench /Users/brooklyn/workspace/github/oxc-node > pnpm --filter=bench bench > [email protected] bench /Users/brooklyn/workspace/github/oxc-node/packages/bench > node --import @oxc-node/core/register index.ts ┌─────────┬──────────────┬─────────┬────────────────────┬──────────┬─────────┐ │ (index) │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │ ├─────────┼──────────────┼─────────┼────────────────────┼──────────┼─────────┤ │ 0 │ '@swc/core' │ '1,539' │ 649450.8402597416 │ '±0.44%' │ 1540 │ │ 1 │ 'oxc' │ '7,004' │ 142768.56045681832 │ '±0.07%' │ 7005 │ │ 2 │ 'typescript' │ '304' │ 3284196.5836065547 │ '±2.80%' │ 305 │ └─────────┴──────────────┴─────────┴────────────────────┴──────────┴─────────┘ ```
1 parent 63c72d6 commit 347f8be

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

packages/bench/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { readFile } from 'node:fs/promises'
22
import { join } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
34

45
import { transformSync } from '@swc/core'
56
import { transform as oxc } from '@oxc-node/core'
67
import { Bench } from 'tinybench'
7-
import { fileURLToPath } from 'node:url'
8+
import ts from 'typescript'
89

910
const bench = new Bench({ time: 1000 })
1011

@@ -30,6 +31,17 @@ bench
3031
.add('oxc', () => {
3132
oxc('ajax.ts', fixture)
3233
})
34+
.add('typescript', () => {
35+
ts.transpileModule(fixture, {
36+
fileName: 'ajax.ts',
37+
compilerOptions: {
38+
target: ts.ScriptTarget.ESNext,
39+
module: ts.ModuleKind.ESNext,
40+
isolatedModules: true,
41+
sourceMap: true,
42+
},
43+
})
44+
})
3345

3446
await bench.warmup() // make results more reliable, ref: https://github.com/tinylibs/tinybench/pull/50
3547
await bench.run()

packages/bench/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@oxc-node/core": "workspace:*",
1111
"@swc/core": "=1.6.7",
1212
"tinybench": "^2.8.0",
13-
"rxjs": "^7.8.1"
13+
"rxjs": "^7.8.1",
14+
"typescript": "^5.5.3"
1415
}
1516
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)