[Haskell-cafe] Array, Vector, Bytestring
silvio.frischi at gmail.com
Tue Jun 4 18:49:52 CEST 2013
> Just to clarify for those on the sidelines, the issue is duplication of
> implementation details, rather than duplication of functionality?
Well to me, that is not the main issue. The main issue is that you have
to study all of them and depending on which libraries you want to use
have to convert between them, which could be expensive and is definitely
I made a few simple benchmarks comparing the three libraries you can
find the code attached.
this is compiled with -O2
# simple sum of 1000000 Word8 elements
Unboxed Vector 1.114060 ms
Storable Vector 795.1207 us
Primitive Vector 1.116145 ms
ByteString 9.076256 ms
array library has no fold or sum function
# simple sum of 1000000 more or less randomly chosen elements
Unboxed Vector (unsafe) 33.74364 ms
Storable Vector (unsafe) 50.27273 ms
Storable Vector (safe) 67.01634 ms
Primitive Vector (unsafe) 56.29919 ms
ByteString (unsafe) 19.29611 ms
ByteString (safe) 18.29065 ms
UArray (safe) 46.88719 ms
unsafe does not exist for array
So Unboxed can be better than Storable but doesn't need to be.
Also, which implementation is faster depends very much on the problem at
hand. And array is just missing half the needed features.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2738 bytes
Desc: not available
More information about the Haskell-Cafe