line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
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
|
0
|
|
|
|
|
Date date; |
22
|
0
|
0
|
|
|
|
|
for (int i = 0; i < 1000; ++i) date.set(str); |
|
|
0
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
void bench_rparse (string_view str) { |
26
|
0
|
0
|
|
|
|
|
DateRel rel; |
27
|
0
|
0
|
|
|
|
|
for (int i = 0; i < 1000; ++i) rel = str; |
|
|
0
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
uint64_t bench_strftime (string_view format) { |
31
|
0
|
0
|
|
|
|
|
auto date = Date::now(); |
32
|
0
|
|
|
|
|
|
RETVAL = 0; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
for (int i = 0; i < 1000; ++i) { |
35
|
0
|
0
|
|
|
|
|
auto res = date.strftime(format); |
36
|
0
|
|
|
|
|
|
RETVAL += res.length(); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
uint64_t bench_tzget (string_view tz) { |
41
|
0
|
|
|
|
|
|
RETVAL = 0; |
42
|
0
|
0
|
|
|
|
|
for (int i = 0; i < 1000; ++i) RETVAL += (uint64_t)panda::time::tzget(tz).get(); |
|
|
0
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
void bench_hints_get () { |
46
|
0
|
0
|
|
|
|
|
for (int i = 0; i < 1000; ++i) Scope::Hints::exists(xs::date::strict_hint_name); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
bool get_strict_hint () { |
50
|
0
|
0
|
|
|
|
|
RETVAL = Scope::Hints::exists(xs::date::strict_hint_name); |
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
|
0
|
|
|
|
|
if (ix == 0) while(epoch++ < max_epoch) gmtime(epoch, &date); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
else if (ix == 1) while(epoch++ < max_epoch) localtime(epoch, &date); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
RETVAL = Array::create(); |
62
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.sec)); |
|
|
0
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.min)); |
|
|
0
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.hour)); |
|
|
0
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.mday)); |
|
|
0
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.mon)); |
|
|
0
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.year)); |
|
|
0
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.wday)); |
|
|
0
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.yday)); |
|
|
0
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.isdst)); |
|
|
0
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.gmtoff)); |
|
|
0
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.zone)); |
|
|
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
|
0
|
|
|
|
|
if (ix == 0) while(epoch++ < max_epoch) gmtime_r(&epoch, &date); |
|
|
0
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
else if (ix == 1) while(epoch++ < max_epoch) localtime_r(&epoch, &date); |
|
|
0
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
RETVAL = Array::create(); |
82
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_sec)); |
|
|
0
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_min)); |
|
|
0
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_hour)); |
|
|
0
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_mday)); |
|
|
0
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_mon)); |
|
|
0
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_year)); |
|
|
0
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_wday)); |
|
|
0
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_yday)); |
|
|
0
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_isdst)); |
|
|
0
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_gmtoff)); |
|
|
0
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
RETVAL.push(Simple(date.tm_zone)); |
|
|
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
|
0
|
|
|
|
|
else if (ix == 1) while (i++ < cnt) RETVAL += timegml(&date); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
else if (ix == 2) while (i++ < cnt) RETVAL += timelocal(&date); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
else if (ix == 3) while (i++ < cnt) RETVAL += timelocall(&date); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
113
|
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
|
0
|
|
|
|
|
if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date); |
|
|
0
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
else if (ix == 1) while (i++ < cnt) RETVAL += timelocal(&date); |
|
|
0
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
#endif |