[Haskell-cafe] Performance question

Ben Lippmeier Ben.Lippmeier at anu.edu.au
Thu Feb 26 05:44:30 EST 2009


On 26/02/2009, at 9:27 PM, haskell at kudling.de wrote:
>
> Currently i can only imagine to define a data type in order to use  
> unboxed Ints instead of the accumulator tuple.

That would probably help a lot. It would also help to use two separate  
Double# parameters instead of the tuple.

> The thing is that i don't see in the profile output yet what to  
> improve.
> There are some allocations going on in "main", but i don't know what  
> causes it.
>
>> The first thing I would do is replace your
>> isInCircle :: (Floating a, Ord a)  => (a,a) -> Bool
>> with
>> isInCircle :: (Double, Double) -> Bool
>
> Can you point me to why that matters?

At the machine level, GHC treats the (Floating a, Ord a) as an extra  
argument to the function. This argument holds function pointers that  
tell it how to perform multiplication and <= for the unknown type 'a'.  
If you use Double instead of 'a', then it's more likely to use the  
actual machine op.

Ben.




More information about the Haskell-Cafe mailing list