[Haskell-beginners] Data.Binary.Get for large files

Daniel Fischer daniel.is.fischer at web.de
Thu Apr 29 21:18:05 EDT 2010


Am Freitag 30 April 2010 02:46:08 schrieb MAN:
> I can't find the error in your code (assuming there is an error), so I'm
> checking the code you didn't write, and the only thing that set off an
> alarm was...
>
> getFloat64le :: Get Double
> getFloat64le = getFloat (ByteCount 8) $ splitBytes . reverse
>
> splitBytes :: [Word8] -> RawFloat
>
> ...that every chunk read in the Get monad is being reversed, so that you
> can take one float (and you are taking in over 26 million floats) in
> little endian. I really don't know if this hits performance, but I
> assume the C equivalent would be reading an array in reverse order.
> I am more than willing to believe this is not the cause of such
> performance loss, but can't find a reason.

The reversing doesn't matter much, using getFloat64be takes very nearly the 
same time.

>
>
> PS1: "(e == True)" == "e"

Yes!

>
> PS2:
> I know it's not important, but I can't help it: that is not an average
> you're computing...

Sort of a weighted average, where double #k is weighted 2^(k-1-n).



More information about the Beginners mailing list