@@ -7,120 +7,274 @@ import (
77
88func BenchmarkCreateFromStdTime (b * testing.B ) {
99 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+ })
1424}
1525
1626func 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+ })
2140}
2241
2342func 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+ })
2856}
2957
3058func 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+ })
3572}
3673
3774func 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+ })
4288}
4389
4490func 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+ })
49104}
50105
51106func 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+ })
56120}
57121
58122func 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+ })
63136}
64137
65138func 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+ })
70152}
71153
72154func 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+ })
77168}
78169
79170func 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+ })
84184}
85185
86186func 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+ })
91200}
92201
93202func 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+ })
98216}
99217
100218func 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+ })
105232}
106233
107234func 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+ })
112248}
113249
114250func 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+ })
119264}
120265
121266func 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+ })
126280}
0 commit comments