I find mktime cost too much time on __tz_convert
which will read /etc/localtime
every time to get current timezone.
However, if we assume timezone never change, if only take one call to __tz_convert
to get current timezone, which I think can reduce much time.
However, I wonder how to achieve this? There are no field in std::tm
that I can put my timezone into. And I do not want to re-implement mktime
from scratch, because seems it has lots of corner case, such as DST.
EDIT
... OR is it safe to just call __mktime_internal
with a special __localtime_r
that does nothing?
EDIT2
I think I may wrong about why mktime is slow in my case.
In my benchmark, most time are cost in __tz_convert
, for a lock __libc_lock_lock (tzset_lock);
. So maybe it is not related to cat /etc/localtime
?