3 ms·
somewhat off-topic, but I want to share hyperfine[1], which is nearly purpose-built for measuring this kind of performance: $ hyperfine --shell=none "node
by alright2565 3y ago
somewhat off-topic, but I want to share hyperfine[1], which is nearly purpose-built for measuring this kind of performance:
$ hyperfine --shell=none "node -e ''" "python -c pass" "perl -e ''" "php -r ''" "bash -c ''" "echo"
Benchmark 1: node -e ''
Time (mean ± σ): 87.3 ms ± 8.0 ms [User: 69.8 ms, System: 18.4 ms]
Range (min … max): 77.9 ms … 111.1 ms 31 runs
Benchmark 2: python -c pass
Time (mean ± σ): 24.4 ms ± 5.6 ms [User: 17.5 ms, System: 6.7 ms]
Range (min … max): 15.8 ms … 31.3 ms 97 runs
Benchmark 3: perl -e ''
Time (mean ± σ): 2.8 ms ± 0.6 ms [User: 0.9 ms, System: 1.8 ms]
Range (min … max): 1.7 ms … 3.9 ms 863 runs
Benchmark 4: php -r ''
Time (mean ± σ): 19.3 ms ± 4.2 ms [User: 8.9 ms, System: 10.0 ms]
Range (min … max): 12.1 ms … 24.8 ms 241 runs
Benchmark 5: bash -c ''
Time (mean ± σ): 4.9 ms ± 0.8 ms [User: 2.8 ms, System: 1.8 ms]
Range (min … max): 2.6 ms … 6.4 ms 552 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Benchmark 6: echo
Time (mean ± σ): 1.2 ms ± 0.3 ms [User: 0.7 ms, System: 0.3 ms]
Range (min … max): 0.8 ms … 2.1 ms 2237 runs
Summary
echo ran
2.41 ± 0.89 times faster than perl -e ''
4.17 ± 1.39 times faster than bash -c ''
16.37 ± 5.91 times faster than php -r ''
20.74 ± 7.64 times faster than python -c pass
74.21 ± 22.49 times faster than node -e ''
(tested with node 21.5.0, python 3.11.6, perl 5.38.1, php 8.2.14, and bash 5.2.21 on Ryzen 2700X)
[1]: https://github.com/sharkdp/hyperfine https://github.com/sharkdp/hyperfine