[ros-dev] Speed Tests (was: ping Alex regarding log2() for scheduler)

Royce Mitchell III royce3 at ev1.net
Wed Mar 23 21:24:54 CET 2005


Alex Ionescu wrote:

>
> Addon = 16;
> if ((IntMask = Mask >> 16)) {
>     Addon = 0;
>     IntMask = Mask;
> }
> if (IntMask && 0xFFFFFF00) {
>     Addon += 8;
> }
> HighBit = LogTable256[(Mask >> Addon)] + Addon;
>
methinks there's bugs there, use this instead:

int highest_bit_tabled ( unsigned int i )
{
    int ret = 0;
    if ( i > 0xffff )
        i >>= 16, ret = 16;
    if ( i > 0xff )
        i >>= 8, ret += 8;
    return ret + LogTable256[i];
}

also, FWIW, I've tried the following three tests:

( i > 0xffff )

( i & 0xffff0000 )

( i >> 16 )

and the first is the fastest on my a64




More information about the Ros-dev mailing list