in reply to Re: Most Significant Set Bit
in thread Most Significant Set Bit

I timed those two functions along with the following:
sub by_string { my $n = shift; return length(sprintf "%b", $n) - 1; }
I tested with high bits using int rand(2**64), medium bits int rand(2**32) and lower bits int rand(2**16) for 1e6 iterations.
log linear sprintf 0.2917 0.4427 0.3370 avg_sig=62 0.2786 2.8430 0.3056 avg_sig=30 0.2826 4.1060 0.2986 avg_sig=14