Sadly when testing JavaScript, it's not that simple. Whichever one you run first usually has an advantage, and chrome often optimizes "bad code" to run as good as "good code" when other browser engines do not.

Much less a flat number of iterations and just pulling the time doesn't account for timer rollover or jitter, which can skew the results wildly across runs. It often helps to wait for timer rollover and then track how many runs can be done in a fixed amount of time.

But you're right, it's better to bench than to assume. I should build a full test and then make a proper article out of that.

Also funny you called it "optimised" by using "let', something that should make them all SLOWER given that derpy useless waste of time construct makes separate stack frames.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store