| 1 |
|
| #include <xs.h> |
| 2 |
|
| #include <xs/date.h> |
| 3 |
|
| #include <xs/Scope.h> |
| 4 |
|
| #include <panda/date.h> |
| 5 |
|
| #include <cstring> |
| 6 |
|
| |
| 7 |
|
| using namespace xs; |
| 8 |
|
| using namespace panda::date; |
| 9 |
|
| using panda::string; |
| 10 |
|
| using panda::string_view; |
| 11 |
|
| |
| 12 |
|
| #if !defined(_WIN32) && !defined(sun) && !defined(__sun) |
| 13 |
|
| #define DATE_TEST_SYS |
| 14 |
|
| #endif |
| 15 |
|
| |
| 16 |
|
| |
| 17 |
|
| MODULE = MyTest PACKAGE = MyTest |
| 18 |
|
| PROTOTYPES: DISABLE |
| 19 |
|
| |
| 20 |
|
| void bench_parse (string_view str) { |
| 21 |
0 |
▶ | Date date; |
Branch: 1 branch
| Branch | True | False | Total |
| Date date; |
0 |
0 |
0 |
|
| 22 |
0 |
▶ | for (int i = 0; i < 1000; ++i) date.set(str); |
Branch: 2 branches
| Branch | True | False | Total |
| for (int i = 0; i < 1000; ++i) date.set(str); |
0 |
0 |
0 |
| for (int i = 0; i < 1000; ++i) date.set(str); |
0 |
0 |
0 |
|
| 23 |
|
| } |
| 24 |
|
| |
| 25 |
|
| void bench_rparse (string_view str) { |
| 26 |
0 |
▶ | DateRel rel; |
Branch: 1 branch
| Branch | True | False | Total |
| DateRel rel; |
0 |
0 |
0 |
|
| 27 |
0 |
▶ | for (int i = 0; i < 1000; ++i) rel = str; |
Branch: 2 branches
| Branch | True | False | Total |
| for (int i = 0; i < 1000; ++i) rel = str; |
0 |
0 |
0 |
| for (int i = 0; i < 1000; ++i) rel = str; |
0 |
0 |
0 |
|
| 28 |
|
| } |
| 29 |
|
| |
| 30 |
|
| uint64_t bench_strftime (string_view format) { |
| 31 |
0 |
▶ | auto date = Date::now(); |
Branch: 1 branch
| Branch | True | False | Total |
| auto date = Date::now(); |
0 |
0 |
0 |
|
| 32 |
0 |
| RETVAL = 0; |
| 33 |
|
| |
| 34 |
0 |
▶ | for (int i = 0; i < 1000; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (int i = 0; i < 1000; ++i) { |
0 |
0 |
0 |
|
| 35 |
0 |
▶ | auto res = date.strftime(format); |
Branch: 1 branch
| Branch | True | False | Total |
| auto res = date.strftime(format); |
0 |
0 |
0 |
|
| 36 |
0 |
| RETVAL += res.length(); |
| 37 |
0 |
| } |
| 38 |
|
| } |
| 39 |
|
| |
| 40 |
|
| uint64_t bench_tzget (string_view tz) { |
| 41 |
0 |
| RETVAL = 0; |
| 42 |
0 |
▶ | for (int i = 0; i < 1000; ++i) RETVAL += (uint64_t)panda::time::tzget(tz).get(); |
Branch: 2 branches
| Branch | True | False | Total |
| for (int i = 0; i < 1000; ++i) RETVAL += (uint64_t)panda::time::tzget(tz).get(); |
0 |
0 |
0 |
| for (int i = 0; i < 1000; ++i) RETVAL += (uint64_t)panda::time::tzget(tz).get(); |
0 |
0 |
0 |
|
| 43 |
|
| } |
| 44 |
|
| |
| 45 |
|
| void bench_hints_get () { |
| 46 |
0 |
▶ | for (int i = 0; i < 1000; ++i) Scope::Hints::exists(xs::date::strict_hint_name); |
Branch: 1 branch
| Branch | True | False | Total |
| for (int i = 0; i < 1000; ++i) Scope::Hints::exists(xs::date::strict_hint_name); |
0 |
0 |
0 |
|
| 47 |
|
| } |
| 48 |
|
| |
| 49 |
|
| bool get_strict_hint () { |
| 50 |
0 |
▶ | RETVAL = Scope::Hints::exists(xs::date::strict_hint_name); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = Scope::Hints::exists(xs::date::strict_hint_name); |
0 |
0 |
0 |
|
| 51 |
|
| } |
| 52 |
|
| |
| 53 |
|
| #ifdef DATE_TEST_SYS |
| 54 |
|
| |
| 55 |
|
| Array gmtime_bench (ptime_t epoch) : ALIAS(localtime_bench=1) { |
| 56 |
|
| datetime date; |
| 57 |
0 |
| ptime_t max_epoch = epoch + 10000; |
| 58 |
0 |
▶ | if (ix == 0) while(epoch++ < max_epoch) gmtime(epoch, &date); |
Branch: 3 branches
| Branch | True | False | Total |
| if (ix == 0) while(epoch++ < max_epoch) gmtime(epoch, &date); |
0 |
0 |
0 |
| if (ix == 0) while(epoch++ < max_epoch) gmtime(epoch, &date); |
0 |
0 |
0 |
| if (ix == 0) while(epoch++ < max_epoch) gmtime(epoch, &date); |
0 |
0 |
0 |
|
| 59 |
0 |
▶ | else if (ix == 1) while(epoch++ < max_epoch) localtime(epoch, &date); |
Branch: 3 branches
| Branch | True | False | Total |
| else if (ix == 1) while(epoch++ < max_epoch) localtime(epoch, &date); |
0 |
0 |
0 |
| else if (ix == 1) while(epoch++ < max_epoch) localtime(epoch, &date); |
0 |
0 |
0 |
| else if (ix == 1) while(epoch++ < max_epoch) localtime(epoch, &date); |
0 |
0 |
0 |
|
| 60 |
|
| |
| 61 |
0 |
▶ | RETVAL = Array::create(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = Array::create(); |
0 |
0 |
0 |
|
| 62 |
0 |
▶ | RETVAL.push(Simple(date.sec)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.sec)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.sec)); |
0 |
0 |
0 |
|
| 63 |
0 |
▶ | RETVAL.push(Simple(date.min)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.min)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.min)); |
0 |
0 |
0 |
|
| 64 |
0 |
▶ | RETVAL.push(Simple(date.hour)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.hour)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.hour)); |
0 |
0 |
0 |
|
| 65 |
0 |
▶ | RETVAL.push(Simple(date.mday)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.mday)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.mday)); |
0 |
0 |
0 |
|
| 66 |
0 |
▶ | RETVAL.push(Simple(date.mon)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.mon)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.mon)); |
0 |
0 |
0 |
|
| 67 |
0 |
▶ | RETVAL.push(Simple(date.year)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.year)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.year)); |
0 |
0 |
0 |
|
| 68 |
0 |
▶ | RETVAL.push(Simple(date.wday)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.wday)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.wday)); |
0 |
0 |
0 |
|
| 69 |
0 |
▶ | RETVAL.push(Simple(date.yday)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.yday)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.yday)); |
0 |
0 |
0 |
|
| 70 |
0 |
▶ | RETVAL.push(Simple(date.isdst)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.isdst)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.isdst)); |
0 |
0 |
0 |
|
| 71 |
0 |
▶ | RETVAL.push(Simple(date.gmtoff)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.gmtoff)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.gmtoff)); |
0 |
0 |
0 |
|
| 72 |
0 |
▶ | RETVAL.push(Simple(date.zone)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.zone)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.zone)); |
0 |
0 |
0 |
|
| 73 |
|
| } |
| 74 |
|
| |
| 75 |
|
| Array posix_gmtime_bench (time_t epoch) : ALIAS(posix_localtime_bench=1) { |
| 76 |
|
| struct tm date; |
| 77 |
0 |
| time_t max_epoch = epoch + 10000; |
| 78 |
0 |
▶ | if (ix == 0) while(epoch++ < max_epoch) gmtime_r(&epoch, &date); |
Branch: 2 branches
| Branch | True | False | Total |
| if (ix == 0) while(epoch++ < max_epoch) gmtime_r(&epoch, &date); |
0 |
0 |
0 |
| if (ix == 0) while(epoch++ < max_epoch) gmtime_r(&epoch, &date); |
0 |
0 |
0 |
|
| 79 |
0 |
▶ | else if (ix == 1) while(epoch++ < max_epoch) localtime_r(&epoch, &date); |
Branch: 2 branches
| Branch | True | False | Total |
| else if (ix == 1) while(epoch++ < max_epoch) localtime_r(&epoch, &date); |
0 |
0 |
0 |
| else if (ix == 1) while(epoch++ < max_epoch) localtime_r(&epoch, &date); |
0 |
0 |
0 |
|
| 80 |
|
| |
| 81 |
0 |
▶ | RETVAL = Array::create(); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = Array::create(); |
0 |
0 |
0 |
|
| 82 |
0 |
▶ | RETVAL.push(Simple(date.tm_sec)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_sec)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_sec)); |
0 |
0 |
0 |
|
| 83 |
0 |
▶ | RETVAL.push(Simple(date.tm_min)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_min)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_min)); |
0 |
0 |
0 |
|
| 84 |
0 |
▶ | RETVAL.push(Simple(date.tm_hour)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_hour)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_hour)); |
0 |
0 |
0 |
|
| 85 |
0 |
▶ | RETVAL.push(Simple(date.tm_mday)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_mday)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_mday)); |
0 |
0 |
0 |
|
| 86 |
0 |
▶ | RETVAL.push(Simple(date.tm_mon)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_mon)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_mon)); |
0 |
0 |
0 |
|
| 87 |
0 |
▶ | RETVAL.push(Simple(date.tm_year)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_year)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_year)); |
0 |
0 |
0 |
|
| 88 |
0 |
▶ | RETVAL.push(Simple(date.tm_wday)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_wday)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_wday)); |
0 |
0 |
0 |
|
| 89 |
0 |
▶ | RETVAL.push(Simple(date.tm_yday)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_yday)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_yday)); |
0 |
0 |
0 |
|
| 90 |
0 |
▶ | RETVAL.push(Simple(date.tm_isdst)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_isdst)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_isdst)); |
0 |
0 |
0 |
|
| 91 |
0 |
▶ | RETVAL.push(Simple(date.tm_gmtoff)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_gmtoff)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_gmtoff)); |
0 |
0 |
0 |
|
| 92 |
0 |
▶ | RETVAL.push(Simple(date.tm_zone)); |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL.push(Simple(date.tm_zone)); |
0 |
0 |
0 |
| RETVAL.push(Simple(date.tm_zone)); |
0 |
0 |
0 |
|
| 93 |
|
| } |
| 94 |
|
| |
| 95 |
|
| ptime_t timegm_bench (ptime_t sec, ptime_t min, ptime_t hour, ptime_t mday, ptime_t mon, ptime_t year) : ALIAS(timegml_bench=1, timelocal_bench=2, timelocall_bench=3) { |
| 96 |
0 |
| datetime date; |
| 97 |
|
| date.sec = sec; |
| 98 |
0 |
| date.min = min; |
| 99 |
0 |
| date.hour = hour; |
| 100 |
0 |
| date.mday = mday; |
| 101 |
0 |
| date.mon = mon; |
| 102 |
0 |
| date.year = year; |
| 103 |
0 |
| date.isdst = -1; |
| 104 |
0 |
| |
| 105 |
|
| int i = 0; |
| 106 |
0 |
| int cnt = 10000; |
| 107 |
0 |
| RETVAL = 0; |
| 108 |
0 |
| |
| 109 |
|
| if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date); |
| 110 |
0 |
▶ | else if (ix == 1) while (i++ < cnt) RETVAL += timegml(&date); |
Branch: 3 branches
| Branch | True | False | Total |
| else if (ix == 1) while (i++ < cnt) RETVAL += timegml(&date); |
0 |
0 |
0 |
| else if (ix == 1) while (i++ < cnt) RETVAL += timegml(&date); |
0 |
0 |
0 |
| else if (ix == 1) while (i++ < cnt) RETVAL += timegml(&date); |
0 |
0 |
0 |
|
| 111 |
0 |
▶ | else if (ix == 2) while (i++ < cnt) RETVAL += timelocal(&date); |
Branch: 3 branches
| Branch | True | False | Total |
| else if (ix == 2) while (i++ < cnt) RETVAL += timelocal(&date); |
0 |
0 |
0 |
| else if (ix == 2) while (i++ < cnt) RETVAL += timelocal(&date); |
0 |
0 |
0 |
| else if (ix == 2) while (i++ < cnt) RETVAL += timelocal(&date); |
0 |
0 |
0 |
|
| 112 |
0 |
▶ | else if (ix == 3) while (i++ < cnt) RETVAL += timelocall(&date); |
Branch: 3 branches
| Branch | True | False | Total |
| else if (ix == 3) while (i++ < cnt) RETVAL += timelocall(&date); |
0 |
0 |
0 |
| else if (ix == 3) while (i++ < cnt) RETVAL += timelocall(&date); |
0 |
0 |
0 |
| else if (ix == 3) while (i++ < cnt) RETVAL += timelocall(&date); |
0 |
0 |
0 |
|
| 113 |
0 |
▶ | } |
Branch: 3 branches
| Branch | True | False | Total |
| } |
0 |
0 |
0 |
| } |
0 |
0 |
0 |
| } |
0 |
0 |
0 |
|
| 114 |
|
| |
| 115 |
|
| time_t posix_timegm_bench (int64_t sec, int64_t min, int64_t hour, int64_t mday, int64_t mon, int64_t year) : ALIAS(posix_timelocal_bench=1) { |
| 116 |
|
| struct tm date; |
| 117 |
0 |
| date.tm_sec = sec; |
| 118 |
0 |
| date.tm_min = min; |
| 119 |
0 |
| date.tm_hour = hour; |
| 120 |
0 |
| date.tm_mday = mday; |
| 121 |
0 |
| date.tm_mon = mon; |
| 122 |
0 |
| date.tm_year = year-1900; |
| 123 |
0 |
| date.tm_isdst = -1; |
| 124 |
|
| |
| 125 |
0 |
| int i = 0; |
| 126 |
0 |
| int cnt = 10000; |
| 127 |
0 |
| RETVAL = 0; |
| 128 |
|
| |
| 129 |
0 |
▶ | if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date); |
Branch: 2 branches
| Branch | True | False | Total |
| if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date); |
0 |
0 |
0 |
| if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date); |
0 |
0 |
0 |
|
| 130 |
0 |
▶ | else if (ix == 1) while (i++ < cnt) RETVAL += timelocal(&date); |
Branch: 2 branches
| Branch | True | False | Total |
| else if (ix == 1) while (i++ < cnt) RETVAL += timelocal(&date); |
0 |
0 |
0 |
| else if (ix == 1) while (i++ < cnt) RETVAL += timelocal(&date); |
0 |
0 |
0 |
|
| 131 |
|
| } |
| 132 |
|
| |
| 133 |
|
| #endif |