@@ -119,3 +119,126 @@ func TestTimeMixedCompare(t *testing.T) {
119119 })
120120 }
121121}
122+
123+ func BenchmarkTimeParse (b * testing.B ) {
124+ b .ReportAllocs ()
125+
126+ for name , tc := range testfixtures .TimeParseTestTable {
127+ b .Run (name , func (b * testing.B ) {
128+ b .ResetTimer ()
129+
130+ for range b .N {
131+ _ , _ = TimeParse (tc .Input ) // lint:allow_unhandled
132+ }
133+ })
134+ }
135+ }
136+
137+ func BenchmarkTimeParseParallel (b * testing.B ) {
138+ b .ReportAllocs ()
139+
140+ for name , tc := range testfixtures .TimeParseTestTable {
141+ b .Run (name , func (b * testing.B ) {
142+ b .ResetTimer ()
143+ b .RunParallel (func (pb * testing.PB ) {
144+ for pb .Next () {
145+ _ , _ = TimeParse (tc .Input ) // lint:allow_unhandled
146+ }
147+ })
148+ })
149+ }
150+ }
151+
152+ func BenchmarkTimeCompare (b * testing.B ) {
153+ b .ReportAllocs ()
154+
155+ for name , tc := range testfixtures .TimeCompareStringTestTable {
156+ b .Run (name , func (b * testing.B ) {
157+ b .ResetTimer ()
158+
159+ for range b .N {
160+ _ , _ = TimeCompare (tc .InputA , tc .InputB ) // lint:allow_unhandled
161+ }
162+ })
163+ }
164+ }
165+
166+ func BenchmarkTimeCompareParallel (b * testing.B ) {
167+ b .ReportAllocs ()
168+
169+ for name , tc := range testfixtures .TimeCompareStringTestTable {
170+ b .Run (name , func (b * testing.B ) {
171+ b .ResetTimer ()
172+ b .RunParallel (func (pb * testing.PB ) {
173+ for pb .Next () {
174+ _ , _ = TimeCompare (tc .InputA , tc .InputB ) // lint:allow_unhandled
175+ }
176+ })
177+ })
178+ }
179+ }
180+
181+ func BenchmarkTimeCompareMixed (b * testing.B ) {
182+ b .ReportAllocs ()
183+
184+ for name , tc := range testfixtures .TimeCompareMixedTestTable {
185+ b .Run (name , func (b * testing.B ) {
186+ b .ResetTimer ()
187+
188+ for range b .N {
189+ _ , _ = TimeCompare (tc .InputA , tc .InputB ) // lint:allow_unhandled
190+ }
191+ })
192+ }
193+ }
194+
195+ func BenchmarkTimeCompareMixedParallel (b * testing.B ) {
196+ b .ReportAllocs ()
197+
198+ for name , tc := range testfixtures .TimeCompareMixedTestTable {
199+ b .Run (name , func (b * testing.B ) {
200+ b .ResetTimer ()
201+ b .RunParallel (func (pb * testing.PB ) {
202+ for pb .Next () {
203+ _ , _ = TimeCompare (tc .InputA , tc .InputB ) // lint:allow_unhandled
204+ }
205+ })
206+ })
207+ }
208+ }
209+
210+ func FuzzTimeParse (f * testing.F ) {
211+ for _ , tc := range testfixtures .TimeParseTestTable {
212+ f .Add (tc .Input )
213+ }
214+
215+ f .Fuzz (
216+ func (_ * testing.T , in string ) {
217+ _ , _ = TimeParse (in ) // lint:allow_unhandled
218+ },
219+ )
220+ }
221+
222+ func FuzzTimeCompare (f * testing.F ) {
223+ for _ , tc := range testfixtures .TimeCompareStringTestTable {
224+ f .Add (tc .InputA , tc .InputB )
225+ }
226+
227+ f .Fuzz (
228+ func (_ * testing.T , inA , inB string ) {
229+ _ , _ = TimeCompare (inA , inB ) // lint:allow_unhandled
230+ },
231+ )
232+ }
233+
234+ func FuzzTimeCompareMixed (f * testing.F ) {
235+ for _ , tc := range testfixtures .TimeCompareMixedTestTable {
236+ f .Add (tc .InputA , tc .InputB )
237+ }
238+
239+ f .Fuzz (
240+ func (_ * testing.T , inA string , inB int64 ) {
241+ _ , _ = TimeCompare (inA , inB ) // lint:allow_unhandled
242+ },
243+ )
244+ }
0 commit comments