Queries regarding the library and performance statistics

13 views
Skip to first unread message

Kannamraju P

unread,
Aug 24, 2017, 8:48:00 AM8/24/17
to cctz
Hi All,
  
  As part of evaluating different timezone utilities for a C++ app ran int CCTZ  , looking for some info on  .

1. Is there a standard routine which can take CIVIL time , zone and convert to epoch.
2. Is the Timezone information seeded in the code or is loaded from some file . If its loaded from some file 
does it get loaded every time we invoke an conversion API .
3. Are there any performance statistics for the library API's 

Any help is really appreciated.

Thanks,
Raju. 
   

Bradley White

unread,
Aug 25, 2017, 2:06:51 AM8/25/17
to cctz
Hi Raju,


On Thursday, August 24, 2017 at 8:48:00 AM UTC-4, Kannamraju P wrote:
1. Is there a standard routine which can take CIVIL time , zone and convert to epoch.

Yes.  Indeed conversion between civil times and absolute times via a time zone is the primary purpose of the library.

In your case, to convert a civil time in a time zone to an absolute time, you'd use something along the lines of:

  cctz::time_zone tz = ...;
  cctz::civil_second cs = ...;
  cctz::time_point<cctz::sys_seconds> tp = cctz::convert(cs, tz);

If you need to fully account for skipped/repeated civil times, look at cctz::time_zone::lookup(const cctz::civil_second&).
 
2. Is the Timezone information seeded in the code or is loaded from some file . If its loaded from some file 
does it get loaded every time we invoke an conversion API .

It is loaded from a file by default, but you can also override how a time-zone name maps to its zoneinfo data.

The zoneinfo data for a named zone is loaded once (for the life of the program), on first reference.
 
3. Are there any performance statistics for the library API's

The src/benchmarks.cc file has a set of micro benchmarks.  You should be able to run them on your own platform (although we only support it using bazel).

For what it's worth, I currently get these numbers:

Run on host (32 X 2600 MHz CPUs); 2017-08-24T22:31:48.73777955-07:00
CPU: Intel Sandybridge with HyperThreading (16 cores) dL1:32KB dL2:256KB dL3:20MB
Benchmark                                    Time(ns)        CPU(ns)     Iterations
-----------------------------------------------------------------------------------
BM_Difference_Days                                 19.8           19.8     35230223
BM_Step_Days                                       14.7           14.6     47679141
BM_Zone_LoadUTCTimeZoneFirst                       33.5           33.5     20559067
BM_Zone_LoadUTCTimeZoneLast                        35.8           35.8     19354916
BM_Zone_LoadTimeZoneFirst                      408455         407232           1704
BM_Zone_LoadTimeZoneCached                         47.6           47.6     14628558
BM_Zone_LoadLocalTimeZoneCached                   137            137        5044375
BM_Zone_LoadAllTimeZonesFirst                  159723         159083           4447
BM_Zone_LoadAllTimeZonesCached                     63.2           63.1     10000000
BM_Zone_TimeZoneImplGetImplicit                     2.81           2.81   250544964
BM_Zone_TimeZoneImplGetExplicit                     1.97           1.97   357661845
BM_Zone_UTCTimeZone                                 2.52           2.52   278138596
BM_Time_ToDateTime_BaseTime                        54.4           54.3     10000000
BM_Time_ToDateTime_Libc                            83.7           83.5      8548525
BM_Time_ToDateTimeUTC_BaseTime                     46.1           46.1     14820691
BM_Time_ToDateTimeUTC_Libc                         45.9           45.9     15042716
BM_Time_FromDateTime_BaseTime                      52.9           52.7     10000000
BM_Time_FromDateTime_Libc                         533            532        1000000
BM_Time_FromDateTimeUTC_BaseTime                   40.6           40.5     17221911
BM_Time_FromDateTimeDay0_BaseTime                  80.9           80.7      8760811
BM_Time_FromDateTimeDay0_Libc                     614            614        1000000
BM_Format_FormatTime/0                            565            564        1000000  %a, %d %b %Y %H:%M:%S %z
BM_Format_FormatTime/1                            449            448        1564818  %d %b %Y %H:%M:%S %z
BM_Format_FormatTime/2                            418            417        1641786  %Y-%m-%dT%H:%M:%E*S%Ez
BM_Format_FormatTime/3                            373            372        1864626  %Y-%m-%dT%H:%M:%S%Ez
BM_Format_FormatTime/4                            340            340        2049963  %Y-%m-%dT%H:%M:%S
BM_Format_FormatTime/5                            232            231        2970344  %Y-%m-%d
BM_Format_ParseTime/0                            1277           1275         560828  %a, %d %b %Y %H:%M:%S %z
BM_Format_ParseTime/1                             830            828         834518  %d %b %Y %H:%M:%S %z
BM_Format_ParseTime/2                             354            353        1969853  %Y-%m-%dT%H:%M:%E*S%Ez
BM_Format_ParseTime/3                             328            328        2131377  %Y-%m-%dT%H:%M:%S%Ez
BM_Format_ParseTime/4                             232            231        3009379  %Y-%m-%dT%H:%M:%S
BM_Format_ParseTime/5                             155            154        4522413  %Y-%m-%d

[Note:  In the To/FromDateTime comparisons with Libc above, the "BaseTime" numbers refer to CCTZ.  I'll fix those names.]

Bradley
Reply all
Reply to author
Forward
0 new messages