Output:PHP Code:void ColComparing()
{
Col c1(100,100,100,240), c2(100,100,99,240);
uint i, ii=0;
asm volatile(
";"
::"r"(c1), "r"(c2), "r"(&ii):);
ResetAndStartTimer("Asm ");
for(i= 0; i<loops; ++i)
{
asm volatile(
"cmpl %0,%1;"
"jne endA;"
"incl (%2);"
"endA:;"
::"r"(c1), "r"(c2), "r"(&ii):);
}
StopAndLog();
DD(ii);
ii=0;
ResetAndStartTimer("4byte");
for(i= 0; i<loops; ++i)
{
if(*((uint32*)&c1)==*((uint32*)&c2)) ++ii;
}
StopAndLog();
DD(ii);
ii=0;
ResetAndStartTimer("1byte");
for(i= 0; i<loops; ++i)
{
if(c1.b == c2.b && c1.g == c2.g && c1.r == c2.r && c1.a==c2.a) ++ii;
}
StopAndLog();
DD(ii);
testInt += c1.b+ii;
}
Loops: 1410065408
Asm 1.359000
4byte 3.531000
1byte 1.828000
How is it that the 4byte comparison is so much slower?
It should exactly the same as the Asm.
I am using gcc with ALL optimizations turned on.


Reply With Quote