[Haskell-cafe] Performance question

haskell at kudling.de haskell at kudling.de
Thu Feb 26 05:27:03 EST 2009


Hi,

thanks for your input.

>You can get reasonable numeric performance out of GHC, but you need to  
>work at it. There is some advice in the GHC manual at 
>http://www.haskell.org/ghc/docs/latest/html/users_guide/faster.html 

I am using -O2 and strictness already.
Currently i can only imagine to define a data type in order to use unboxed Ints instead of the accumulator 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?

>
>Ben.
>
>
>
>On 26/02/2009, at 8:53 PM, haskell at kudling.de wrote:
>
>> Hi,
>>
>> i have compared a C++ implementation with a Haskell implementation  
>> of the Monte Carlo Pi approximation:
>>
>> http://lennart.kudling.de/haskellPi/
>>
>> The Haskell version is 100 times slower and i wonder whether i do  
>> something obvious wrong.
>>
>> Profiling says that the majority of the time is spend in "main". But  
>> i have no idea where.
>>
>> Can someone give me a hint?
>>
>> Thanks,
>> Lenny
>>
>>
>


More information about the Haskell-Cafe mailing list