File tree Expand file tree Collapse file tree 4 files changed +43
-18
lines changed
Expand file tree Collapse file tree 4 files changed +43
-18
lines changed Original file line number Diff line number Diff line change 4848 " register.cjs"
4949 ],
5050 "scripts" : {
51+ "bench" : " node test/bench.mjs && deno -A test/bench.mjs && bun --bun test/bench.mjs" ,
5152 "build" : " pnpm clean && NODE_ENV=production pnpm webpack" ,
5253 "clean" : " rm -rf dist" ,
5354 "dev" : " pnpm clean && pnpm webpack --watch" ,
Original file line number Diff line number Diff line change 1+ import { createRequire } from "node:module" ;
2+
3+ const runtime =
4+ // eslint-disable-next-line unicorn/no-nested-ternary
5+ "Bun" in globalThis ? "bun" : "Deno" in globalThis ? "deno" : "node" ;
6+
7+ console . log ( "--------------------------------" ) ;
8+
9+ console . log (
10+ `> ${ runtime } ${ globalThis . Deno ?. version . deno || globalThis . Bun ?. version || process . version } ` ,
11+ ) ;
12+
13+ const require = createRequire ( import . meta. url ) ;
14+
15+ const initialMem = process . memoryUsage ( ) . heapUsed ;
16+ let lastMem = initialMem ;
17+ const logMemory = ( label ) => {
18+ const mem = process . memoryUsage ( ) . heapUsed ;
19+ console . log (
20+ label ,
21+ "+" + ( ( mem - lastMem ) / 1024 / 1024 ) . toFixed ( 2 ) + " MB" + " (heap)" ,
22+ ) ;
23+ lastMem = mem ;
24+ } ;
25+
26+ console . time ( "jiti:load" ) ;
27+ const createJiti = require ( "../lib/jiti.cjs" ) ;
28+ console . timeEnd ( "jiti:load" ) ;
29+ logMemory ( "jiti:load:" ) ;
30+
31+ console . time ( "jiti:init" ) ;
32+ const jiti = createJiti ( import . meta. url , {
33+ moduleCache : false ,
34+ fsCache : false ,
35+ } ) ;
36+ console . timeEnd ( "jiti:init" ) ;
37+
38+ for ( let i = 0 ; i < 4 ; i ++ ) {
39+ console . time ( "jiti:import:ts" ) ;
40+ await jiti . import ( "../fixtures/typescript/test.ts" ) ;
41+ console . timeEnd ( "jiti:import:ts" ) ;
42+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments