[Haskell-cafe] Performance help
ryani.spam at gmail.com
Tue Nov 13 17:50:00 EST 2007
Sure, if the ring size is a power of two, and a is greater than or equal
to 0, then
a `mod` ringSize == a .&. (ringSize - 1)
a `mod` 8 == a .&. 7
a `mod` 256 == a .&. 255
On 11/13/07, Justin Bailey <jgbailey at gmail.com> wrote:
> On Nov 13, 2007 2:21 PM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> > Never mind, I realized this is a ring buffer with `mod` s. That's
> > slow operation when you're doing code as tight as this. If you can
> > guarantee the ring is a power of 2 in size you can use a mask instead,
> > use my original suggestion of deriving rules from the previous rule and
> > new bit; the initial state is determined by the last bits in the buffer
> > you never wrap.
> I can't guarantee the ring is a power of 2 but do you feel like
> explaining the mask suggestion anyways?
> Thanks for the bits suggestion - I'll see if that helps performance at
> all. It looks like you have to be very careful in which concrete type
> you choose or you'll get a lot of conversion going on.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe