[Haskell-cafe] Performance question

Roman Leshchinskiy rl at cse.unsw.edu.au
Thu Mar 18 18:02:03 EDT 2010

On 19/03/2010, at 08:48, Daniel Fischer wrote:

> Am Donnerstag 18 März 2010 21:57:34 schrieb Daniel Fischer:
>> Contrary to my expectations, however, using unboxed arrays is slower
>> than straight arrays (in my tests).
> However, a few {-# SPECIALISE #-} pragmas set the record straight.

This is because without specialising, unsafeAt is a straight (inlineable) function call for boxed arrays but is overloaded and hence much slower for unboxed ones. In general, unboxed arrays tend to be slower in generic code. The only real solution is making functions such as binarySearch INLINE.


More information about the Haskell-Cafe mailing list