https://github.com/halfzebra/tail-recursion-benchmark
🧪 JavaScript benchmark for tail recursion optimisation
https://github.com/halfzebra/tail-recursion-benchmark
benchmark javascript recursion
Last synced: about 1 month ago
JSON representation
🧪 JavaScript benchmark for tail recursion optimisation
- Host: GitHub
- URL: https://github.com/halfzebra/tail-recursion-benchmark
- Owner: halfzebra
- Created: 2019-06-15T15:38:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-23T16:17:41.000Z (over 2 years ago)
- Last Synced: 2025-01-20T10:14:04.143Z (over 1 year ago)
- Topics: benchmark, javascript, recursion
- Language: JavaScript
- Homepage:
- Size: 201 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tail-recursion-benchmark
This repo with a benchmark of [Factorial](https://en.wikipedia.org/wiki/Factorial) with tail recursion optimisation.
I wanted to see how fast tail-recursive functions are compared to the implementation using loops in JavaScript.
## Run locally
```sh
npm install
npm bench
```
## Results
```sh
recursive x 1,164 ops/sec ±0.89% (89 runs sampled)
tailRecursive x 707,965 ops/sec ±0.60% (91 runs sampled)
loop x 3,503,258 ops/sec ±0.62% (89 runs sampled)
Fastest is loop
```