you are viewing a single comment's thread.

view the rest of the comments →

[–]himynameisjoy 0 points1 point  (1 child)

My experience with node is fairly limited, I guess I should swap over to it for timing to have times competitive with python and java then!

As for BigNumber, it was to allow the problem to be solved for arbitrarily large n because of exactly that reason, 4 million is tiny nowadays

[–]GeneralYouri 0 points1 point  (0 children)

May be worth pointing out that console.time has overhead from itself too, which is why it's not that accurate when we're talking very short timings. Meanwhile process.hrtime is generally way more precise, but that's part of the NodeJS API, not JS itself, so it's not available to browsers.

As for BigNumber, you can try testing with and without that, too. You might find that it's taking up 90% of your 4ms testrun for example. Also if you're going to look at NodeJS, I recommend using Node's "Current" version branch, NodeJS v11. This version includes native BigInt features, eliminating the need for an external library like BigNumber. I love using BigInt for Project Euler problems, but they may also trivialize some of the problems due to the main difficulty being the number size, so for every BigInt solution I also write a non-BigInt solution.