Skip to content

Commit f535207

Browse files
Add benchmark
1 parent d85763d commit f535207

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/run
22
/dist
3+
*.log

README.md

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# run
1+
# 🦊 run
22

3-
A small utility for running `package.json` scripts and npm modules.
3+
A small utility for running `package.json` scripts and npm modules. `run` is written in Go and executes scripts faster than `npm`, `yarn`, or `pnpm` since it can skip the Node.js startup time.
44

55
### Installation
66

@@ -14,6 +14,36 @@ brew install jacobwgillespie/tap/run
1414
run [script] [flags]
1515
```
1616

17+
## Benchmarks
18+
19+
Informally, `run` is about 25-50 times faster than Node package managers at starting scripts:
20+
21+
```
22+
Benchmark 1: npm run echo-example
23+
Time (mean ± σ): 142.4 ms ± 2.1 ms [User: 132.6 ms, System: 22.0 ms]
24+
Range (min … max): 139.7 ms … 150.5 ms 21 runs
25+
26+
Benchmark 2: yarn run echo-example
27+
Time (mean ± σ): 91.1 ms ± 0.7 ms [User: 77.5 ms, System: 14.3 ms]
28+
Range (min … max): 89.5 ms … 92.5 ms 33 runs
29+
30+
Benchmark 3: pnpm run echo-example
31+
Time (mean ± σ): 204.9 ms ± 1.2 ms [User: 192.4 ms, System: 16.1 ms]
32+
Range (min … max): 202.7 ms … 206.9 ms 14 runs
33+
34+
Benchmark 4: ./run echo-example
35+
Time (mean ± σ): 3.6 ms ± 0.2 ms [User: 1.4 ms, System: 1.6 ms]
36+
Range (min … max): 3.5 ms … 5.0 ms 726 runs
37+
38+
Summary
39+
'./run echo-example' ran
40+
24.98 ± 1.37 times faster than 'yarn run echo-example'
41+
39.05 ± 2.20 times faster than 'npm run echo-example'
42+
56.19 ± 3.07 times faster than 'pnpm run echo-example'
43+
```
44+
45+
If you would like to run the benchmark on your local machine, ensure you have [hyperfine](https://github.com/sharkdp/hyperfine) installed, then run `npm run benchmark` (or just `run benchark` if `run` is already installed 🦊).
46+
1747
## License
1848

1949
MIT License, see `LICENSE`.

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"scripts": {
3+
"benchmark": "./support/benchmark.sh",
4+
"echo-example": "echo hello world"
5+
}
6+
}

support/benchmark.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
go build
4+
hyperfine --warmup 5 -N 'npm run echo-example' 'yarn run echo-example' 'pnpm run echo-example' './run echo-example'

0 commit comments

Comments
 (0)