[Haskell-cafe] Performance question

Sittampalam, Ganesh ganesh.sittampalam at credit-suisse.com
Thu Feb 26 05:46:52 EST 2009


Ben Lippmeier wrote:
 
>>> 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.   

I'd recommend use of a SPECIALIZE pragma instead of rewriting the code
itself:

http://www.haskell.org/ghc/docs/latest/html/users_guide/pragmas.html
(section 8.13.8)

Ganesh

=============================================================================== 
 Please access the attached hyperlink for an important electronic communications disclaimer: 
 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
 =============================================================================== 
 


More information about the Haskell-Cafe mailing list