dimanche 18 février 2018

Weird performance hit during number comparison

While writing a function that increasing a variable within specific condition on Chrome 64 Window 10, I found out about this weird thing:

Run this test suite for context

Why the first one is slower than other 3, and when on Edge, the first one and last one runs slower than other 2, and on Fire Fox 58 all of those 4 are the same?

I tried to replace the temp + 0; with 1 + 0;, the first one will run as fast as other 3.

You can try this, this and this for more cases.


This is my result:

When x is float and y is <= 1, x < y will slow ?

When x is negative float and y >= -1, x > y will slow ?

Why this is happen only on Chrome and Edge? (I did not test on Opera and Safari and other browsers).

Aucun commentaire:

Enregistrer un commentaire