Skip to content

Commit

Permalink
bench: add TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Jul 14, 2024
1 parent 63c72d6 commit 95a7dc7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/bench/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'

import { transformSync } from '@swc/core'
import { transform as oxc } from '@oxc-node/core'
import { Bench } from 'tinybench'
import { fileURLToPath } from 'node:url'
import ts from 'typescript'

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

Expand All @@ -30,6 +31,17 @@ bench
.add('oxc', () => {
oxc('ajax.ts', fixture)
})
.add('typescript', () => {
ts.transpileModule(fixture, {
fileName: 'ajax.ts',
compilerOptions: {
target: ts.ScriptTarget.ESNext,
module: ts.ModuleKind.ESNext,
isolatedModules: true,
sourceMap: true,
},
})
})

await bench.warmup() // make results more reliable, ref: https://github.com/tinylibs/tinybench/pull/50
await bench.run()
Expand Down
3 changes: 2 additions & 1 deletion packages/bench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@oxc-node/core": "workspace:*",
"@swc/core": "=1.6.7",
"tinybench": "^2.8.0",
"rxjs": "^7.8.1"
"rxjs": "^7.8.1",
"typescript": "^5.5.3"
}
}

0 comments on commit 95a7dc7

Please sign in to comment.