[Haskell-cafe] Array, Vector, Bytestring

Mike Ledger mike at quasimal.com
Tue Jun 4 22:50:12 CEST 2013


On 05/06/13 02:49, silvio wrote:
>> 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 annoying.
>
> 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.
>
> Silvio
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
array does provide folding functions, found in its Foldable and 
Traversable instances.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130605/d44c7ae8/attachment.htm>


More information about the Haskell-Cafe mailing list