@@ -7,120 +7,274 @@ import (
7
7
8
8
func BenchmarkCreateFromStdTime (b * testing.B ) {
9
9
now := time .Now ().In (time .Local )
10
- b .ResetTimer ()
11
- for n := 0 ; n < b .N ; n ++ {
12
- CreateFromStdTime (now )
13
- }
10
+
11
+ b .Run ("without timezone" , func (b * testing.B ) {
12
+ b .ResetTimer ()
13
+ for n := 0 ; n < b .N ; n ++ {
14
+ CreateFromStdTime (now )
15
+ }
16
+ })
17
+
18
+ b .Run ("with timezone" , func (b * testing.B ) {
19
+ b .ResetTimer ()
20
+ for n := 0 ; n < b .N ; n ++ {
21
+ CreateFromStdTime (now , PRC )
22
+ }
23
+ })
14
24
}
15
25
16
26
func BenchmarkCreateFromTimestamp (b * testing.B ) {
17
- b .ResetTimer ()
18
- for n := 0 ; n < b .N ; n ++ {
19
- CreateFromTimestamp (1649735755 , PRC )
20
- }
27
+ b .Run ("without timezone" , func (b * testing.B ) {
28
+ b .ResetTimer ()
29
+ for n := 0 ; n < b .N ; n ++ {
30
+ CreateFromTimestamp (1649735755 )
31
+ }
32
+ })
33
+
34
+ b .Run ("with timezone" , func (b * testing.B ) {
35
+ b .ResetTimer ()
36
+ for n := 0 ; n < b .N ; n ++ {
37
+ CreateFromTimestamp (1649735755 , PRC )
38
+ }
39
+ })
21
40
}
22
41
23
42
func BenchmarkCreateFromTimestampMilli (b * testing.B ) {
24
- b .ResetTimer ()
25
- for n := 0 ; n < b .N ; n ++ {
26
- CreateFromTimestampMilli (1649735755981 , PRC )
27
- }
43
+ b .Run ("without timezone" , func (b * testing.B ) {
44
+ b .ResetTimer ()
45
+ for n := 0 ; n < b .N ; n ++ {
46
+ CreateFromTimestampMilli (1649735755 )
47
+ }
48
+ })
49
+
50
+ b .Run ("with timezone" , func (b * testing.B ) {
51
+ b .ResetTimer ()
52
+ for n := 0 ; n < b .N ; n ++ {
53
+ CreateFromTimestampMilli (1649735755 , PRC )
54
+ }
55
+ })
28
56
}
29
57
30
58
func BenchmarkCreateFromTimestampMicro (b * testing.B ) {
31
- b .ResetTimer ()
32
- for n := 0 ; n < b .N ; n ++ {
33
- CreateFromTimestampMicro (1649735755981566 , PRC )
34
- }
59
+ b .Run ("without timezone" , func (b * testing.B ) {
60
+ b .ResetTimer ()
61
+ for n := 0 ; n < b .N ; n ++ {
62
+ CreateFromTimestampMicro (1649735755 )
63
+ }
64
+ })
65
+
66
+ b .Run ("with timezone" , func (b * testing.B ) {
67
+ b .ResetTimer ()
68
+ for n := 0 ; n < b .N ; n ++ {
69
+ CreateFromTimestampMicro (1649735755 , PRC )
70
+ }
71
+ })
35
72
}
36
73
37
74
func BenchmarkCreateFromTimestampNano (b * testing.B ) {
38
- b .ResetTimer ()
39
- for n := 0 ; n < b .N ; n ++ {
40
- CreateFromTimestampNano (1649735755981566888 , PRC )
41
- }
75
+ b .Run ("without timezone" , func (b * testing.B ) {
76
+ b .ResetTimer ()
77
+ for n := 0 ; n < b .N ; n ++ {
78
+ CreateFromTimestampNano (1649735755 )
79
+ }
80
+ })
81
+
82
+ b .Run ("with timezone" , func (b * testing.B ) {
83
+ b .ResetTimer ()
84
+ for n := 0 ; n < b .N ; n ++ {
85
+ CreateFromTimestampNano (1649735755 , PRC )
86
+ }
87
+ })
42
88
}
43
89
44
90
func BenchmarkCreateFromDateTime (b * testing.B ) {
45
- b .ResetTimer ()
46
- for n := 0 ; n < b .N ; n ++ {
47
- CreateFromDateTime (2020 , 8 , 5 , 13 , 14 , 15 , PRC )
48
- }
91
+ b .Run ("without timezone" , func (b * testing.B ) {
92
+ b .ResetTimer ()
93
+ for n := 0 ; n < b .N ; n ++ {
94
+ CreateFromDateTime (2020 , 8 , 5 , 13 , 14 , 15 )
95
+ }
96
+ })
97
+
98
+ b .Run ("with timezone" , func (b * testing.B ) {
99
+ b .ResetTimer ()
100
+ for n := 0 ; n < b .N ; n ++ {
101
+ CreateFromDateTime (2020 , 8 , 5 , 13 , 14 , 15 , PRC )
102
+ }
103
+ })
49
104
}
50
105
51
106
func BenchmarkCreateFromDateTimeMilli (b * testing.B ) {
52
- b .ResetTimer ()
53
- for n := 0 ; n < b .N ; n ++ {
54
- CreateFromDateTimeMilli (2020 , 8 , 5 , 13 , 14 , 15 , 999 , PRC )
55
- }
107
+ b .Run ("without timezone" , func (b * testing.B ) {
108
+ b .ResetTimer ()
109
+ for n := 0 ; n < b .N ; n ++ {
110
+ CreateFromDateTimeMilli (2020 , 8 , 5 , 13 , 14 , 15 , 999 )
111
+ }
112
+ })
113
+
114
+ b .Run ("with timezone" , func (b * testing.B ) {
115
+ b .ResetTimer ()
116
+ for n := 0 ; n < b .N ; n ++ {
117
+ CreateFromDateTimeMilli (2020 , 8 , 5 , 13 , 14 , 15 , 999 , PRC )
118
+ }
119
+ })
56
120
}
57
121
58
122
func BenchmarkCreateFromDateTimeMicro (b * testing.B ) {
59
- b .ResetTimer ()
60
- for n := 0 ; n < b .N ; n ++ {
61
- CreateFromDateTimeMicro (2020 , 8 , 5 , 13 , 14 , 15 , 999999 , PRC )
62
- }
123
+ b .Run ("without timezone" , func (b * testing.B ) {
124
+ b .ResetTimer ()
125
+ for n := 0 ; n < b .N ; n ++ {
126
+ CreateFromDateTimeMicro (2020 , 8 , 5 , 13 , 14 , 15 , 999999 )
127
+ }
128
+ })
129
+
130
+ b .Run ("with timezone" , func (b * testing.B ) {
131
+ b .ResetTimer ()
132
+ for n := 0 ; n < b .N ; n ++ {
133
+ CreateFromDateTimeMicro (2020 , 8 , 5 , 13 , 14 , 15 , 999999 , PRC )
134
+ }
135
+ })
63
136
}
64
137
65
138
func BenchmarkCreateFromDateTimeNano (b * testing.B ) {
66
- b .ResetTimer ()
67
- for n := 0 ; n < b .N ; n ++ {
68
- CreateFromDateTimeNano (2020 , 8 , 5 , 13 , 14 , 15 , 999999999 , PRC )
69
- }
139
+ b .Run ("without timezone" , func (b * testing.B ) {
140
+ b .ResetTimer ()
141
+ for n := 0 ; n < b .N ; n ++ {
142
+ CreateFromDateTimeNano (2020 , 8 , 5 , 13 , 14 , 15 , 999999999 )
143
+ }
144
+ })
145
+
146
+ b .Run ("with timezone" , func (b * testing.B ) {
147
+ b .ResetTimer ()
148
+ for n := 0 ; n < b .N ; n ++ {
149
+ CreateFromDateTimeNano (2020 , 8 , 5 , 13 , 14 , 15 , 999999999 , PRC )
150
+ }
151
+ })
70
152
}
71
153
72
154
func BenchmarkCreateFromDate (b * testing.B ) {
73
- b .ResetTimer ()
74
- for n := 0 ; n < b .N ; n ++ {
75
- CreateFromDate (2020 , 8 , 5 , PRC )
76
- }
155
+ b .Run ("without timezone" , func (b * testing.B ) {
156
+ b .ResetTimer ()
157
+ for n := 0 ; n < b .N ; n ++ {
158
+ CreateFromDate (2020 , 8 , 5 )
159
+ }
160
+ })
161
+
162
+ b .Run ("with timezone" , func (b * testing.B ) {
163
+ b .ResetTimer ()
164
+ for n := 0 ; n < b .N ; n ++ {
165
+ CreateFromDate (2020 , 8 , 5 , PRC )
166
+ }
167
+ })
77
168
}
78
169
79
170
func BenchmarkCreateFromDateMilli (b * testing.B ) {
80
- b .ResetTimer ()
81
- for n := 0 ; n < b .N ; n ++ {
82
- CreateFromDateMilli (2020 , 8 , 5 , 999 , PRC )
83
- }
171
+ b .Run ("without timezone" , func (b * testing.B ) {
172
+ b .ResetTimer ()
173
+ for n := 0 ; n < b .N ; n ++ {
174
+ CreateFromDateMilli (2020 , 8 , 5 , 999 )
175
+ }
176
+ })
177
+
178
+ b .Run ("with timezone" , func (b * testing.B ) {
179
+ b .ResetTimer ()
180
+ for n := 0 ; n < b .N ; n ++ {
181
+ CreateFromDateMilli (2020 , 8 , 5 , 999 , PRC )
182
+ }
183
+ })
84
184
}
85
185
86
186
func BenchmarkCreateFromDateMicro (b * testing.B ) {
87
- b .ResetTimer ()
88
- for n := 0 ; n < b .N ; n ++ {
89
- CreateFromDateMicro (2020 , 8 , 5 , 999999 , PRC )
90
- }
187
+ b .Run ("without timezone" , func (b * testing.B ) {
188
+ b .ResetTimer ()
189
+ for n := 0 ; n < b .N ; n ++ {
190
+ CreateFromDateMicro (2020 , 8 , 5 , 999999 )
191
+ }
192
+ })
193
+
194
+ b .Run ("with timezone" , func (b * testing.B ) {
195
+ b .ResetTimer ()
196
+ for n := 0 ; n < b .N ; n ++ {
197
+ CreateFromDateMicro (2020 , 8 , 5 , 999999 , PRC )
198
+ }
199
+ })
91
200
}
92
201
93
202
func BenchmarkCreateFromDateNano (b * testing.B ) {
94
- b .ResetTimer ()
95
- for n := 0 ; n < b .N ; n ++ {
96
- CreateFromDateNano (2020 , 8 , 5 , 999999999 , PRC )
97
- }
203
+ b .Run ("without timezone" , func (b * testing.B ) {
204
+ b .ResetTimer ()
205
+ for n := 0 ; n < b .N ; n ++ {
206
+ CreateFromDateNano (2020 , 8 , 5 , 999999999 )
207
+ }
208
+ })
209
+
210
+ b .Run ("with timezone" , func (b * testing.B ) {
211
+ b .ResetTimer ()
212
+ for n := 0 ; n < b .N ; n ++ {
213
+ CreateFromDateNano (2020 , 8 , 5 , 999999999 , PRC )
214
+ }
215
+ })
98
216
}
99
217
100
218
func BenchmarkCreateFromTime (b * testing.B ) {
101
- b .ResetTimer ()
102
- for n := 0 ; n < b .N ; n ++ {
103
- CreateFromTime (13 , 14 , 15 , PRC )
104
- }
219
+ b .Run ("without timezone" , func (b * testing.B ) {
220
+ b .ResetTimer ()
221
+ for n := 0 ; n < b .N ; n ++ {
222
+ CreateFromTime (13 , 14 , 15 )
223
+ }
224
+ })
225
+
226
+ b .Run ("with timezone" , func (b * testing.B ) {
227
+ b .ResetTimer ()
228
+ for n := 0 ; n < b .N ; n ++ {
229
+ CreateFromTime (13 , 14 , 15 , PRC )
230
+ }
231
+ })
105
232
}
106
233
107
234
func BenchmarkCreateFromTimeMilli (b * testing.B ) {
108
- b .ResetTimer ()
109
- for n := 0 ; n < b .N ; n ++ {
110
- CreateFromTimeMilli (13 , 14 , 15 , 999 , PRC )
111
- }
235
+ b .Run ("without timezone" , func (b * testing.B ) {
236
+ b .ResetTimer ()
237
+ for n := 0 ; n < b .N ; n ++ {
238
+ CreateFromTimeMilli (13 , 14 , 15 , 999 )
239
+ }
240
+ })
241
+
242
+ b .Run ("with timezone" , func (b * testing.B ) {
243
+ b .ResetTimer ()
244
+ for n := 0 ; n < b .N ; n ++ {
245
+ CreateFromTimeMilli (13 , 14 , 15 , 999 , PRC )
246
+ }
247
+ })
112
248
}
113
249
114
250
func BenchmarkCreateFromTimeMicro (b * testing.B ) {
115
- b .ResetTimer ()
116
- for n := 0 ; n < b .N ; n ++ {
117
- CreateFromTimeMicro (13 , 14 , 15 , 999999 , PRC )
118
- }
251
+ b .Run ("without timezone" , func (b * testing.B ) {
252
+ b .ResetTimer ()
253
+ for n := 0 ; n < b .N ; n ++ {
254
+ CreateFromTimeMicro (13 , 14 , 15 , 999999 )
255
+ }
256
+ })
257
+
258
+ b .Run ("with timezone" , func (b * testing.B ) {
259
+ b .ResetTimer ()
260
+ for n := 0 ; n < b .N ; n ++ {
261
+ CreateFromTimeMicro (13 , 14 , 15 , 999999 , PRC )
262
+ }
263
+ })
119
264
}
120
265
121
266
func BenchmarkCreateFromTimeNano (b * testing.B ) {
122
- b .ResetTimer ()
123
- for n := 0 ; n < b .N ; n ++ {
124
- CreateFromTimeNano (13 , 14 , 15 , 999999999 , PRC )
125
- }
267
+ b .Run ("without timezone" , func (b * testing.B ) {
268
+ b .ResetTimer ()
269
+ for n := 0 ; n < b .N ; n ++ {
270
+ CreateFromTimeNano (13 , 14 , 15 , 999999999 )
271
+ }
272
+ })
273
+
274
+ b .Run ("with timezone" , func (b * testing.B ) {
275
+ b .ResetTimer ()
276
+ for n := 0 ; n < b .N ; n ++ {
277
+ CreateFromTimeNano (13 , 14 , 15 , 999999999 , PRC )
278
+ }
279
+ })
126
280
}
0 commit comments