mirror of
https://github.com/araddon/dateparse.git
synced 2024-12-05 05:30:13 +08:00
bench: add benchmark for github.com/simplereach/timeutils
This commit is contained in:
parent
1d15b8a8bb
commit
bce34723db
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/simplereach/timeutils"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -17,6 +19,11 @@ BenchmarkDateparseParseAny 500000 5752 ns/op 0 B/op 0 alloc
|
||||
BenchmarkShotgunParse-4 50000 30045 ns/op 13136 B/op 169 allocs/op
|
||||
BenchmarkParseAny-4 200000 8627 ns/op 144 B/op 3 allocs/op
|
||||
|
||||
// ifreddyrondon Laptop MacBook Pro (Retina, Mid 2012) March 2018
|
||||
BenchmarkShotgunParse-8 50000 33940 ns/op 13136 B/op 169 allocs/op
|
||||
BenchmarkParseAny-8 200000 10146 ns/op 912 B/op 29 allocs/op
|
||||
BenchmarkParseDateString-8 10000 123077 ns/op 208 B/op 13 allocs/op
|
||||
|
||||
*/
|
||||
func BenchmarkShotgunParse(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
@ -37,6 +44,15 @@ func BenchmarkParseAny(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkParseDateString(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, dateStr := range testDates {
|
||||
timeutils.ParseDateString(dateStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
testDates = []string{
|
||||
"2012/03/19 10:11:59",
|
||||
|
Loading…
Reference in New Issue
Block a user