We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seems like Go standard library was fixed since this library was introduced, so now time.Parse beats datetime.ParseAny:
time.Parse
datetime.ParseAny
package bench import ( "testing" "time" "github.com/araddon/dateparse" "github.com/stretchr/testify/require" ) func TestDateEquivalence(t *testing.T) { format := "2006-01-02" input := "1988-11-20" out1, err := time.Parse(format, input) require.NotNil(t, out1) require.NoError(t, err) out2, err := dateparse.ParseAny(input) require.NotNil(t, out2) require.NoError(t, err) require.True(t, out1.Equal(out2)) } func TestTimeEquivalence(t *testing.T) { format := "2006-01-02 15:04:05.999999" input := "1988-11-20 11:12:13.444444" out1, err := time.Parse(format, input) require.NotNil(t, out1) require.NoError(t, err) out2, err := dateparse.ParseAny(input) require.NotNil(t, out2) require.NoError(t, err) require.True(t, out1.Equal(out2)) } func BenchmarkDateParseStdLib(b *testing.B) { format := "2006-01-02" input := "1988-11-20" for i := 0; i < b.N; i++ { out, err := time.Parse(format, input) require.NotNil(b, out) require.NoError(b, err) } } func BenchmarkDateParseAraddonDateparse(b *testing.B) { input := "1988-11-20" for i := 0; i < b.N; i++ { out, err := dateparse.ParseStrict(input) require.NotNil(b, out) require.NoError(b, err) } } func BenchmarkTimeParseStdLib(b *testing.B) { format := "2006-01-02 15:04:05.999999" input := "1988-11-20 11:12:13.444444" for i := 0; i < b.N; i++ { out, err := time.Parse(format, input) require.NotNil(b, out) require.NoError(b, err) } } func BenchmarkTimeParseAraddonTimeparse(b *testing.B) { input := "1988-11-20 11:12:13.444444" for i := 0; i < b.N; i++ { out, err := dateparse.ParseAny(input) require.NotNil(b, out) require.NoError(b, err) } }
Results:
cpu: 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz BenchmarkDateParseStdLib BenchmarkDateParseStdLib-16 2813982 417.9 ns/op BenchmarkDateParseAraddonDateparse BenchmarkDateParseAraddonDateparse-16 2003248 575.2 ns/op BenchmarkTimeParseStdLib BenchmarkTimeParseStdLib-16 2293155 520.0 ns/op BenchmarkTimeParseAraddonTimeparse BenchmarkTimeParseAraddonTimeparse-16 1585695 749.0 ns/op
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Seems like Go standard library was fixed since this library was introduced, so now
time.Parse
beatsdatetime.ParseAny
:Results:
The text was updated successfully, but these errors were encountered: