1
1
import { compile , CompileOptions } from 'https://deno.land/x/[email protected] /tsc/compile.ts'
2
2
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'
4
5
5
6
function tsc ( source : string , opts : any ) {
6
7
const compileOptions : CompileOptions = {
@@ -42,8 +43,12 @@ async function benchmark() {
42
43
43
44
const d1 = { d : 0 , min : 0 , max : 0 }
44
45
const d2 = { d : 0 , min : 0 , max : 0 }
45
- const n = 10
46
+ const n = 5
46
47
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
+ }
47
52
for ( const { code, filename } of sourceFiles ) {
48
53
const t = performance . now ( )
49
54
for ( let i = 0 ; i < n ; i ++ ) {
@@ -58,10 +63,15 @@ async function benchmark() {
58
63
}
59
64
d1 . d += d
60
65
}
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
+ }
61
71
for ( const { code, filename } of sourceFiles ) {
62
72
const t = performance . now ( )
63
73
for ( let i = 0 ; i < n ; i ++ ) {
64
- transform ( filename , code , {
74
+ transformSync ( filename , code , {
65
75
swcOptions : { target : 'es2020' } ,
66
76
isDev : true
67
77
} )
@@ -82,8 +92,6 @@ async function benchmark() {
82
92
}
83
93
84
94
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 ( )
88
96
await benchmark ( )
89
97
}
0 commit comments