Which method is faster for millions of loops ?
double a, b, c, d, e ,f;
1.
for (int i=0; i<1000000; i++)
{
// simulation which changes the a,b,c,d,e,f values
...
if (a>b)
{
if (c<d)
{
if (e==f)
// do something
}
}
}
2.
for (int i=0; i<1000000; i++)
{
// simulation which changes the a,b,c,d,e,f values
...
if ((a>b) && (c<d) && (e==f))
// do something
}
I was thinking that method 1 would be faster because it skips many if comparisons instead of comparing all the 3 variables at once every time.
Aucun commentaire:
Enregistrer un commentaire