lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


RJP Computing wrote:
> > Open issues:
> > - Lacks an appropriate project name that is not taken yet.
> 
> What about  lBit, Bit, or Bits?

Right now I'm leaning towards "Lua BitOp", but I'm still open to
suggestions.

Also regarding the functionality itself. I forgot to mention
bit.bswap in my last message.

I've benchmarked Lua BitOp against bitlib (using replacement
functions in Lua with shifts/and/or for the missing functionality)
and the upcoming LuaJIT 2.x. It's a trivial microbenchmark with
simple loops like this one:

  local f = bit.bor; local x = 0; for i=1,n do x = x + f(i, 1) end

This was measured on a 3 GHz Core 2 E8400. The loop baseline is
subtracted from the other rows. Time is given in nanoseconds per
iteration, lower is better:

                Lua 5.1.4  Lua 5.1.4  LuaJIT 2.x  LuaJIT 2.x
                + bitlib   + BitOp    -j off      -j on
---------------------------*********------------------------
loop baseline     15.5 ns    15.5 ns     5.2 ns     1.0 ns
tobit             79.5 ns    48.3 ns    10.5 ns     0.0 ns
bnot              77.7 ns    48.9 ns    12.6 ns     0.0 ns
bor/band/bxor    129.5 ns    67.0 ns    13.7 ns     0.0 ns
shifts           102.0 ns    61.4 ns    13.1 ns     0.0 ns
rotates          397.0 ns    62.3 ns    13.1 ns     0.3 ns
bswap           1019.5 ns    50.2 ns    13.1 ns     0.4 ns
---------------------------*********------------------------

[A timing of 0.0 ns means the super-scalar CPU pipeline completely
hides the latency of the bit operation.]

--Mike