Add broader benchmarks

Uses the main test set for a broader stress test.
This commit is contained in:
Klondike Dragon 2023-12-16 08:18:54 -07:00
parent 0c3943eacd
commit 0d2fd5e275

View File

@ -40,6 +40,63 @@ func BenchmarkParseAny(b *testing.B) {
} }
} }
func BenchmarkBigShotgunParse(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for _, t := range testInputs {
// This is the non dateparse traditional approach
_, _ = parseShotgunStyle(t.in)
}
}
}
func BenchmarkBigParseAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for _, t := range testInputs {
_, _ = ParseAny(t.in)
}
}
}
func BenchmarkBigParseIn(b *testing.B) {
b.ReportAllocs()
loc, _ := time.LoadLocation("America/New_York")
for i := 0; i < b.N; i++ {
for _, t := range testInputs {
_, _ = ParseIn(t.in, loc)
}
}
}
func BenchmarkBigParseRetryAmbiguous(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for _, t := range testInputs {
_, _ = ParseAny(t.in, RetryAmbiguousDateWithSwap(true))
}
}
}
func BenchmarkShotgunParseErrors(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for _, t := range testParseErrors {
// This is the non dateparse traditional approach
_, _ = parseShotgunStyle(t.in)
}
}
}
func BenchmarkParseAnyErrors(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for _, t := range testParseErrors {
_, _ = ParseAny(t.in)
}
}
}
/* /*
func BenchmarkParseDateString(b *testing.B) { func BenchmarkParseDateString(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()