mardi 10 février 2015

C++ - strange time mesurements with and without if statement

I stumbled upon a strange duration difference between two equivalent increment syntax.



if(seed != state) ++i;


this notation measures 2.25 ms per 1048576 iterations



i += (seed != state);


and this 2.80 ms per 1048576 iterations.


Shouldn't the second notation be a bit faster than the first? It is to mention, that seed == state happens very rarely.


Thanks for your answers.


Aucun commentaire:

Enregistrer un commentaire