From bce34723db3c5d76b9800226a89d12571e056878 Mon Sep 17 00:00:00 2001 From: Freddy Rondon Date: Sun, 18 Mar 2018 16:07:06 -0300 Subject: [PATCH] bench: add benchmark for github.com/simplereach/timeutils --- bench_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bench_test.go b/bench_test.go index f30eb98..fd0ed57 100644 --- a/bench_test.go +++ b/bench_test.go @@ -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",