This commit is contained in:
Aaron Raddon 2014-12-05 17:10:12 -08:00
parent ceeeb70dcb
commit 148ceeb09c

View File

@ -19,12 +19,13 @@ func BenchmarkShotgunParse(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
for _, dateStr := range testDates { for _, dateStr := range testDates {
parseShotgun(dateStr) // This is the non dateparse traditional approach
parseShotgunStyle(dateStr)
} }
} }
} }
func BenchmarkDateparseParseAny(b *testing.B) { func BenchmarkParseAny(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
for _, dateStr := range testDates { for _, dateStr := range testDates {
@ -102,11 +103,8 @@ var (
ts, err = ParseAny() ts, err = ParseAny()
*/ */
// Normalizes a variety of string representations to a time.Time in UTC. func parseShotgunStyle(raw string) (time.Time, error) {
func parseShotgun(raw string) (time.Time, error) {
// We shouldn't need these, dupes of above
// Well it's not a UNIX timestamp, try ISO standards
for _, format := range timeFormats { for _, format := range timeFormats {
t, err := time.Parse(format, raw) t, err := time.Parse(format, raw)
if err == nil { if err == nil {