Skip to content

Instantly share code, notes, and snippets.

@colinhacks
Last active September 8, 2023 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinhacks/436b6836cd13291a79dd50dcde2d45bf to your computer and use it in GitHub Desktop.
Save colinhacks/436b6836cd13291a79dd50dcde2d45bf to your computer and use it in GitHub Desktop.
Script runner benchmark
{
"name": "sayhi",
"module": "index.ts",
"type": "module",
"dependencies": {
"cowsay": "^1.5.0"
},
"scripts": {
"hi": "echo 'hi'"
}
}
$ hyperfine "bun run hi" "npm run hi" "pnpm run hi" "yarn hi"
Benchmark 1: bun run hi
Time (mean ± σ): 6.3 ms ± 0.7 ms [User: 3.0 ms, System: 2.3 ms]
Range (min … max): 5.7 ms … 13.6 ms 177 runs
Warning: The first benchmarking run for this command was significantly slower than the rest (13.6 ms). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.
Benchmark 2: npm run hi
Time (mean ± σ): 176.4 ms ± 38.5 ms [User: 167.3 ms, System: 31.2 ms]
Range (min … max): 161.6 ms … 285.8 ms 10 runs
Warning: The first benchmarking run for this command was significantly slower than the rest (285.8 ms). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.
Benchmark 3: pnpm run hi
Time (mean ± σ): 259.8 ms ± 17.2 ms [User: 233.7 ms, System: 22.8 ms]
Range (min … max): 248.3 ms … 297.7 ms 10 runs
Warning: The first benchmarking run for this command was significantly slower than the rest (297.7 ms). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.
Benchmark 4: yarn hi
Time (mean ± σ): 131.4 ms ± 13.1 ms [User: 102.4 ms, System: 20.3 ms]
Range (min … max): 126.5 ms … 180.1 ms 16 runs
Warning: The first benchmarking run for this command was significantly slower than the rest (180.1 ms). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.
Summary
'bun run hi' ran
20.79 ± 3.12 times faster than 'yarn hi'
27.91 ± 6.85 times faster than 'npm run hi'
41.11 ± 5.37 times faster than 'pnpm run hi'
$ hyperfine "bun run hi" "npm run hi" "pnpm run hi" "yarn hi"
@colinhacks
Copy link
Author

Requires hyperfine, npm, yarn, pnpm, and bun

@ipenywis
Copy link

ipenywis commented Sep 8, 2023

I gotta do a video about this 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment