A Tale of Two Functions
I have one function that fills an array up to a specified value:
function getNumberArray(maxValue) {
const a
In fact, running this benchmark now, generators at ~2x faster.
I've modified the code slightly (moved let i
) and here is the full gist: https://gist.github.com/antonkatz/6b0911c85ddadae39c434bf8ac32b340
On my machine, these are the results:
Running Array... Total time: 4,022ms Rss: 2,728,939,520 Heap Total: 2,726,199,296 Heap Used: 2,704,236,368
Running Generator... Total time: 2,541ms Rss: 851,968 Heap Total: 0 Heap Used: -5,073,968
I was very curious myself and could not find a proper answer. Thanks @David for providing the test code.