RealFrac methods for Double and Float

Daniel Fischer daniel.is.fischer at web.de
Mon Oct 11 15:12:12 EDT 2010


On Monday 11 October 2010 04:44:24, Antoine Latter wrote:

> I have results from my Intel-based MacBook, 64-bits, GHC 7 rc.

>
> Results from ncgFloat:
>
> Relations for properFraction:
>   Prelude          1.000000
>   C via Integer    0.333999
>   Hs via Integer   0.499852
>   C Int            4.417461
>   Hs Int           4.558648

Puzzle solved. I have run the benchmarks with the latest HEAD and got 
broadly similar results.

GHC's new code generator does some incredible stuff with the code for 
Float's RealFrac instance, properFraction has become about _seven times_ 
faster, floor and ceiling about _thirteen times_ and round about _10.5 
times_ (values for my box, the exact numbers will differ, but the tendency 
will be the same).

Just Wow!

My code for properFraction :: Float -> (Integer, Float) has become 1.7 
times slower when calling out to C, everything else has either changed 
hardly at all or become slightly faster (5-10%).

The overall result is that for Float, in the general case, the current 
implementation is faster and overall the speedups are less impressive than 
they were for 6.12.

So I'll have to re-learn what GHC does with which kind of code.

Cheers,
Daniel


More information about the Libraries mailing list