[Haskell-cafe] instance (Enum a) => IArray UArray a
Mikhail Arefiev
m.arefiev at gmail.com
Fri Jan 20 16:31:42 CET 2012
Is there a reason why there is no instance of (Enum a) => IArray
UArray a (other than that it will require OverlappingInstances and/or
IncoherentInstances if e. g. UArray of Bools is used in the same
code)?
I have written one with the help of StackOverflow
(http://stackoverflow.com/questions/8941386/), here is the source
code:
- UArrays.hs: http://hpaste.org/56728
- BenchmarkUArray.hs: http://hpaste.org/56729
- Makefile: http://hpaste.org/56727
Running the benchmark with +RTS -s on the UArray version shows
1,283,705,968 bytes allocated in the heap
113,304 bytes copied during GC
80,027,864 bytes maximum residency (2 sample(s))
744,128 bytes maximum slop
155 MB total memory in use (0 MB lost due to fragmentation)
versus
567,014,904 bytes allocated in the heap
962,651,888 bytes copied during GC
324,111,008 bytes maximum residency (3 sample(s))
2,887,992 bytes maximum slop
545 MB total memory in use (0 MB lost due to fragmentation)
on the boxed (Array Int Color) version. Also, boxed enum time is
1.75s and unboxed is 0.45s.
The benchmark may be silly (I am not experienced in testing for
Haskell performance), and I would be grateful for any tips on how to
improve it to achieve more accurate measurements.
Does having such thing make any sense?
--
Best regards,
Arefiev
More information about the Haskell-Cafe
mailing list