Yagiz Nizipli

@anonrig

Node.js task runner

anonrig

Recently, I’ve added a task runner to Node.js. This means that instead of running npm run test on your project, you can now run “node —run test”. This change has the goal of reducing the amount of CPU cycles we pay for just running a simple script. Prior to native task runner, it was around 200ms. With the C++ rewrite of the task runner, it is now 20ms.

PR: https://github.com/nodejs/node/pull/52609

❯ hyperfine '../node/main-branch --run test' '../node/cpp-rewrite --run test' 'npm run test' -i
Benchmark 1: ../node/main-branch --run test
  Time (mean ± σ):      33.2 ms ±   0.6 ms    [User: 26.0 ms, System: 4.2 ms]
  Range (min … max):    32.0 ms …  35.6 ms    83 runs

  Warning: Ignoring non-zero exit code.

Benchmark 2: ../node/cpp-rewrite --run test
  Time (mean ± σ):      21.5 ms ±   0.5 ms    [User: 16.7 ms, System: 2.4 ms]
  Range (min … max):    20.7 ms …  23.1 ms    120 runs

  Warning: Ignoring non-zero exit code.

Benchmark 3: npm run test
  Time (mean ± σ):     154.6 ms ±   2.4 ms    [User: 138.4 ms, System: 23.6 ms]
  Range (min … max):   152.1 ms … 159.4 ms    19 runs

  Warning: Ignoring non-zero exit code.

Summary
  ../node/cpp-rewrite --run test ran
    1.54 ± 0.04 times faster than ../node/main-branch --run test
    7.17 ± 0.20 times faster than npm run test