thyme
thyme copied to clipboard
Fast and correct aeson instances for UTCTime
This patch does several things:
- adds benchmark for Thyme aeson
UTCTimeencode and parse vs. Time instances - adds faster encoding/parsing instances for
UTCTime: they used to be ~ twice slower than time, now it is ~2 times faster. I basically copied the encoding instance from aeson and I have written the parsing myself. - adds quickcheck tests for these instances; the instances are correct (i.e.
decode (encode time)) == Just timefor time between 1AC-9999AC). - fixes problems with compilation with older versions of GHC, now it passes the Travis checks completely for all GHC versions
- I didn't touch the
ZonedTimeinstance as it seemed to me it parsed more formats than I would expect (the RFC3339) - if you feel I should change that, send me a note and I could do that. - I have added dependency on the
scannerpackage; the parser is about twice as fast as an identicalattoparsecparser, I think it makes sense
Benchmark results:
benchmarking time encode/time/encode
time 1.097 μs (1.058 μs .. 1.146 μs)
0.990 R² (0.981 R² .. 0.998 R²)
mean 1.072 μs (1.049 μs .. 1.115 μs)
std dev 96.30 ns (57.69 ns .. 168.7 ns)
variance introduced by outliers: 86% (severely inflated)
benchmarking time encode/thyme/encode
time 547.6 ns (537.6 ns .. 566.3 ns)
0.992 R² (0.981 R² .. 0.999 R²)
mean 558.1 ns (545.7 ns .. 583.9 ns)
std dev 55.11 ns (35.69 ns .. 89.25 ns)
variance introduced by outliers: 89% (severely inflated)
benchmarking time decode/time/decode
time 2.467 μs (2.438 μs .. 2.493 μs)
0.999 R² (0.998 R² .. 0.999 R²)
mean 2.475 μs (2.448 μs .. 2.506 μs)
std dev 100.6 ns (82.19 ns .. 128.5 ns)
variance introduced by outliers: 54% (severely inflated)
benchmarking time decode/thyme/decode
time 856.0 ns (850.2 ns .. 862.2 ns)
0.999 R² (0.999 R² .. 1.000 R²)
mean 859.9 ns (852.5 ns .. 868.4 ns)
std dev 25.96 ns (20.86 ns .. 33.31 ns)
variance introduced by outliers: 42% (moderately inflated)