Test script hello.ts:
const res: number[] = [];
for (let i = 0; i < 100000; i++) {
res.push(i*-2);
}
res.sort((a, b) => a - b);
Execution time:
> time ./hello
________________________________________________________
Executed in 47.84 secs fish external
usr time 47.22 secs 0.26 millis 47.22 secs
sys time 0.13 secs 1.14 millis 0.13 secs
> time node hello.ts
________________________________________________________
Executed in 74.17 millis fish external
usr time 61.70 millis 0.33 millis 61.37 millis
sys time 13.00 millis 2.34 millis 10.66 millis
The big culprit is sort. Removing the line shaves of most of the time down to sub 1 second.
scriptc 0.0.32
node 22.21.1
Apple M4 Max
Test script
hello.ts:Execution time:
The big culprit is sort. Removing the line shaves of most of the time down to sub 1 second.
scriptc 0.0.32
node 22.21.1
Apple M4 Max