mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
Merge pull request #50 from ifreddyrondon/master
bench: add benchmark for github.com/simplereach/timeutils
This commit is contained in:
commit
f58c961370
@ -4,6 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"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
|
BenchmarkShotgunParse-4 50000 30045 ns/op 13136 B/op 169 allocs/op
|
||||||
BenchmarkParseAny-4 200000 8627 ns/op 144 B/op 3 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) {
|
func BenchmarkShotgunParse(b *testing.B) {
|
||||||
b.ReportAllocs()
|
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 (
|
var (
|
||||||
testDates = []string{
|
testDates = []string{
|
||||||
"2012/03/19 10:11:59",
|
"2012/03/19 10:11:59",
|
||||||
|
Loading…
Reference in New Issue
Block a user