11import { 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'
58
69function tsc ( source : string , opts : any ) {
710 const compileOptions : CompileOptions = {
@@ -24,19 +27,19 @@ function tsc(source: string, opts: any) {
2427 * - green: >= 10.0 faster as expected
2528 */
2629function colorDiff ( d : number ) {
27- let cf = colors . green
30+ let cf = green
2831 if ( d < 1 ) {
29- cf = colors . red
32+ cf = red
3033 } else if ( d < 10 ) {
31- cf = colors . yellow
34+ cf = yellow
3235 }
3336 return cf ( d . toFixed ( 2 ) + 'x' )
3437}
3538
3639async function benchmark ( ) {
3740 const sourceFiles : Array < { code : string , filename : string } > = [ ]
3841 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 ) ) {
4043 sourceFiles . push ( { code : await Deno . readTextFile ( filename ) , filename } )
4144 }
4245 console . log ( `[benchmark] ${ sourceFiles . length } files` )
@@ -92,6 +95,7 @@ async function benchmark() {
9295}
9396
9497if ( import . meta. main ) {
95- await initWasm ( )
98+ const wasmData = getWasmData ( )
99+ await init ( wasmData )
96100 await benchmark ( )
97101}
0 commit comments