[Development] More on QDateTime / QTimeZone
John Layt
jlayt at kde.org
Sat Sep 14 03:04:45 CEST 2013
On Thursday 12 Sep 2013 13:48:24 Thiago Macieira wrote:
> On quinta-feira, 12 de setembro de 2013 21:06:03, John Layt wrote:
> > * Choose either local msecs or epoch msecs, if epoch then that change
> > can't
> > be done for 5.2
>
> Choose the easiest for you to implement. We're running out of time, so I'd
> rather stick to the implementation you have and your best recommendation.
I've spent the evening writing and running some benchmark tests (amazingly we
didn't have any before). Each benchmark creates a date a day for 10 years and
calls the tested method, so 3650 consecutive dates. The numbers here are from
1000 iterations on my i7. As expected they're a mixed return with some things
faster and some things slower (not all tests shown):
Action Base Msecs %
-------------------------- ----- ----- ----
create(): 0.294 0.392 33
isValid(): 0.339 0.492 45
date(): 0.313 0.632 102
time(): 0.311 0.639 105
timeSpec(): 0.311 0.403 30
offsetFromUtc(): 7.466 9.009 21
toMSecsSinceEpoch(): 6.690 8.836 32
toMSecsSinceEpoch1950(): 7.522 3.642 -52
toMSecsSinceEpoch2050(): 8.618 10.790 25
setDate(): 0.418 0.832 99
setTime(): 0.385 0.820 113
setTimeSpec(): 0.340 0.508 49
setOffsetFromUtc(): 0.347 0.438 26
setMSecsSinceEpoch(): 6.020 2.564 -57
addDays(): 0.701 1.129 61
addMonths(): 1.836 2.270 24
addYears(): 1.826 2.255 23
addMSecs(): 12.820 10.370 -19
toTimeSpec(): 6.900 9.247 34
toOffsetFromUtc(): 7.251 9.292 28
daysTo(): 0.365 0.953 161
msecsTo(): 13.510 17.780 32
equivalent(): 0.367 0.439 20
equivalentUtc(): 6.730 9.018 34
lessThan(): 0.355 0.444 25
lessThanUtc(): 6.714 8.906 33
currentDateTime(): 1.118 0.314 -72
fromMSecsSinceEpoch(): 6.094 2.451 -60
* Things that start with an msecs value (i.e. use localtime) are 60-80% faster
* Things that start with a date and time (i.e. use mktime) are 30% slower.
* Focusing on optimising toMSecsSinceEpoch() will cause most other methods to
speed up, if I remove a tzset call it runs faster than the baseline.
* The getting and setting of the date and time are obviously slower as they
now involve conversions.
* Rather strangely timeSpec() is 30% slower despite now only returning the
member directly instead of having to do a switch based on the member, a few
other calls are equally confusing.
Cheers!
John.
More information about the Development
mailing list