The example as follow, running this section would cost 26 ms.
for(; src_ptr < src_end_ptr;)
{
g = src_ptr[1];
r = src_ptr[2];
if(r == g)
{
h = 0;
}
else
{
h = r + g;
}
s = ((r == 0) ? 0 : g) << 8;
dest_ptr+=3;
src_ptr+=3;
}
But if change it into following section, it would cost more than 80 ms.
for(; src_ptr < src_end_ptr;)
{
g = src_ptr[1];
r = src_ptr[2];
if(r == g)
{
h = 0;
}
else
{
100 * r/(g+1);
}
s = ((r == 0) ? 0 : g) << 8;
dest_ptr+=3;
src_ptr+=3;
}
The difference is just in the ELSE section. And I’m sure it won’t go into ELSE section when running the program. Why the duration is so different? And it should not cost so much time even if it go into ELSE section?