https://github.com/paramdeo/testing-imperative-loops-versus-higher-order-functions-in-javascript
Testing an Imperative Loop versus Higher Order Functions in JavaScript
https://github.com/paramdeo/testing-imperative-loops-versus-higher-order-functions-in-javascript
Last synced: 21 days ago
JSON representation
Testing an Imperative Loop versus Higher Order Functions in JavaScript
- Host: GitHub
- URL: https://github.com/paramdeo/testing-imperative-loops-versus-higher-order-functions-in-javascript
- Owner: paramdeo
- License: mit
- Created: 2023-06-04T20:38:17.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-04T21:18:25.000Z (about 3 years ago)
- Last Synced: 2025-03-02T08:23:48.574Z (over 1 year ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Testing an Imperative Loop vs Higher-Order Functions in JavaScript
Run `npm run test` in the console for a preset benchmark that includes a warmup run for the garbage collector to wake up. The test runs against the following data:
- 1,000,000 Elements of Value 100
- 10,000,000 Elements of Value 250
- 12,345,678 Elements of Value 1337
- 25,000,000 Elements of Value 500
To run against custom data, run `node index.js 5000 50` where `5000` is the size of the array and `50` is the integer value of each element.
> Note: The benchmarks are done via summing all the elements in the array.
>
> Also Note: Testing array sizes above 25 million elements sends the CPU usage above 90%, causing the VM to hang. Don't be a dick to the generous folks at CodeSandbox.