1
1
import { compile , CompileOptions } from 'https://deno.land/x/[email protected] /tsc/compile.ts'
2
- import { colors , createHash , path , walk } from '../deps.ts'
3
- import { initWasm } from './mod.ts'
4
- import { transformSync } from './dist/wasm-pack.js'
2
+ import { walk } from 'https://deno.land/[email protected] /fs/walk.ts'
3
+ import { resolve } from 'https://deno.land/[email protected] /path/mod.ts'
4
+ import { green , red , yellow } from 'https://deno.land/[email protected] /fmt/colors.ts'
5
+ import { createHash } from 'https://deno.land/[email protected] /hash/mod.ts'
6
+ import init , { transformSync } from './dist/wasm-pack.js'
7
+ import getWasmData from './dist/wasm.js'
5
8
6
9
function tsc ( source : string , opts : any ) {
7
10
const compileOptions : CompileOptions = {
@@ -24,19 +27,19 @@ function tsc(source: string, opts: any) {
24
27
* - green: >= 10.0 faster as expected
25
28
*/
26
29
function colorDiff ( d : number ) {
27
- let cf = colors . green
30
+ let cf = green
28
31
if ( d < 1 ) {
29
- cf = colors . red
32
+ cf = red
30
33
} else if ( d < 10 ) {
31
- cf = colors . yellow
34
+ cf = yellow
32
35
}
33
36
return cf ( d . toFixed ( 2 ) + 'x' )
34
37
}
35
38
36
39
async function benchmark ( ) {
37
40
const sourceFiles : Array < { code : string , filename : string } > = [ ]
38
41
const walkOptions = { includeDirs : false , exts : [ 'ts' , '.tsx' ] , skip : [ / [ \. _ ] ( t e s t | d ) \. t s x ? $ / i, / \/ c o m p i l e r \/ / ] }
39
- for await ( const { path : filename } of walk ( path . resolve ( '..' ) , walkOptions ) ) {
42
+ for await ( const { path : filename } of walk ( resolve ( '..' ) , walkOptions ) ) {
40
43
sourceFiles . push ( { code : await Deno . readTextFile ( filename ) , filename } )
41
44
}
42
45
console . log ( `[benchmark] ${ sourceFiles . length } files` )
@@ -92,6 +95,7 @@ async function benchmark() {
92
95
}
93
96
94
97
if ( import . meta. main ) {
95
- await initWasm ( )
98
+ const wasmData = getWasmData ( )
99
+ await init ( wasmData )
96
100
await benchmark ( )
97
101
}
0 commit comments