[Development] More on QDateTime / QTimeZone

John Layt jlayt at kde.org
Tue Sep 17 16:02:31 CEST 2013


On Saturday 14 Sep 2013 17:11:50 John Layt wrote:

> As I said, I'm testing a speed-up for toMSecsSinceEpoch() which makes it
> faster than the old version, which feeds through to most of the other slower
> functions.  I'll also have a look at date() and time() for improvements
> which will also improve things like daysTo(), but they will always be
> slower now.
> 
> One other note, these are only after the msecs change, adding in the
> "missing hour" fix has a marginal effect except on toValid() which balloons
> out to 8.576 as it has to check the tz now.

OK, I've submitted some QDateTime speed-ups, and also the QTimeZone changes  
which are mostly unchanged since last time, just with a couple of 
optimisations and bug fixes.

In QDateTime we make good gains from msecs but then lose some of it to tz, but 
mostly it's still a net gain.  I still need to look at optimising isValid() 
and the date()/time() related code, but I doubt there's much to be gained 
there, we're simply doing more work.

Interestingly the QTimeZone performance figures are a 75% saving over using 
mktime, which gives hope for the plans in 5.3 of using a global QTimeZone 
instead.  The code is 100% slower than using localtime however, but I have 
done no real performance optimisations on the QTimeZone code yet.

Action                      Base    Msecs   Miss    TZ       %
create():                   0.299   0.405   0.494   0.601    101
isValid():                  0.087   0.150   5.642   5.844   6617
date() / time():            0.060   0.288   0.306   0.306    410
offsetFromUtc():            6.929   5.001   5.621   5.689    -18
toMSecsSinceEpoch():        6.256   4.738   5.602   5.738     -8
toMSecsSinceEpoch1950():    7.065   3.374   4.144   4.216    -40
toMSecsSinceEpoch2050():    8.143   6.559   7.615   7.673     -6
toMSecsSinceEpochTz():                              0.143
toMSecsSinceEpoch1950Tz():                          0.145
toMSecsSinceEpoch2050Tz():                          0.298
setDate() / setTime():      0.449   0.817   0.866   0.911    103
setTimeSpec():              0.386   0.406   0.591   0.728     89
setMSecsSinceEpoch():       6.512   3.942   4.161   4.434    -32
setMSecsSinceEpochTz():                             8.666
addDays():                  0.456   0.805   6.123   6.700   1369
addMSecs():                12.600   6.416   7.498   8.314    -34
addMSecsTz():                                       5.698
daysTo():                   0.117   0.591   0.634   0.770    558
currentDateTime():          1.110   0.315   0.358   0.430    -61
fromMSecsSinceEpoch():      6.083   2.480   2.758   3.048    -50
fromMSecsSinceEpochTz():                            8.680

Cheers!

John.




More information about the Development mailing list