Non-controversial rewrite RULES for time package

Liyang HU haskell.org at liyang.hu
Sun Sep 25 12:12:22 CEST 2011


Hi,

The time package is too slow. :(

A prime example is diffUTCTime, which invokes utcTimeToPOSIXSeconds,
which in turn calls realToFrac :: DiffTime -> NominalDiffTime. The
former of these two types notionally accounts for leap seconds, while
the latter does not. Both are newtypes around Data.Fixed.Pico.

Since realToFrac is used in the library only when we know the
difference is within one day, the two notions coincide, and there is
no need to account for leap seconds. Indeed it currently (or rather,
its implementation of "fromRational . toRational") behaves as such.

I propose we include some rewrite RULES to eliminate the round-trip
via Rational. For the attached benchmark, I get a ~4x improvement in
speed.

Discussion period: 2 weeks.

Cheers,
/Liyang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Rewrite-RULES-for-realToFrac-between-Nominal-DiffTim.patch
Type: application/octet-stream
Size: 1814 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/libraries/attachments/20110925/3f9bf994/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bench.hs
Type: application/octet-stream
Size: 560 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/libraries/attachments/20110925/3f9bf994/attachment-0001.obj>


More information about the Libraries mailing list