core.bitop.bt not faster than & ?

Trollgeir via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 17 06:12:15 PST 2014


I've been doing some benchmarking the bt function 
(http://dlang.org/phobos/core_bitop.html) up against a regular 
bit & -operator, and I'm a bit confused over the timings.

I'd expect the bt function to be up to 32 times faster as I 
thought it only compared two bits, and not the entire length of 
bits in the uint. The results I got indicated that there were no 
difference between that and just a regular & condition. In most 
cases, the & was actually a tad bit faster!

Ex.

bt(&element, 16) vs (element & 0b00000000000000001000000000000000)

Can anyone confirm this?


I used a simple std.datetime benchmark template iterating over a 
static array[100000], trying both random values for each entry 
and fixed ones.




More information about the Digitalmars-d-learn mailing list