getting a Binary module into the standard libs

Simon Marlow
Fri, 15 Nov 2002 17:56:10 -0000

> (I'll try to
> do some perf measurements on BinIO vs. BinMem later today, that should
> give us a rough idea).

I did a rough test using GHC's current Binary library hacked to be
standalone.  The test was writing 100000 Ints, followed by reading back
100000 Ints.

Results: using BinMem took about 0.25 secs, BinIO took about 1.1 secs.
That is, BinMem is current 4-5 times faster than BinIO.  I should stress
that this isn't a realistic benchmark.

I conjecture the difference is mostly due to the overhead of going
through the IO library each time a character is written.  When I wrote
the Binary library I was pretty careful to make sure that
putWord8/getWord8 on a BinMem was just straight-line code (that's what
the FastMutInt stuff is for).

The upshot is that if you want really good performance for BinIO, there
will have to be a cache in the BinHandle.