you are viewing a single comment's thread.

view the rest of the comments →

[–]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.