performance improvement for parseDateTime#1098
Merged
julienschmidt merged 1 commit intogo-sql-driver:masterfrom May 17, 2020
chanxuehong:master
Merged
performance improvement for parseDateTime#1098julienschmidt merged 1 commit intogo-sql-driver:masterfrom chanxuehong:master
julienschmidt merged 1 commit intogo-sql-driver:masterfrom
chanxuehong:master
Conversation
julienschmidt
requested changes
May 16, 2020
Member
julienschmidt
left a comment
There was a problem hiding this comment.
Thanks for this pull-request!
Please also indicate who the copyright holder is / make an addition to the AUTHORS file.
utils_test.go
Outdated
| } | ||
| } | ||
|
|
||
| func parseDateTimeOld(str string, loc *time.Location) (t time.Time, err error) { |
Member
There was a problem hiding this comment.
This was useful for demonstrating the diff, but please remove this now. We do not want to keep the old code around.
utils_test.go
Outdated
| return | ||
| } | ||
|
|
||
| func Test_parseDateTime(t *testing.T) { |
Member
There was a problem hiding this comment.
This should be named TestParseDateTime
utils_test.go
Outdated
| } | ||
| } | ||
|
|
||
| func Benchmark_parseDateTime(b *testing.B) { |
utils_test.go
Outdated
| } | ||
| } | ||
|
|
||
| func Benchmark_parseDateTimeOld(b *testing.B) { |
julienschmidt
requested changes
May 17, 2020
AUTHORS
Outdated
| Xiuming Chen <cc at cxm.cc> | ||
| Zhenye Xie <xiezhenye at gmail.com> | ||
| Zhixin Wen <john.wenzhixin at gmail.com> | ||
| Xuehong Chan <chanxuehong at gmail.com> |
Member
There was a problem hiding this comment.
Please keep the list alphabetically sorted, i.e. add your name after Xiuming's.
julienschmidt
approved these changes
May 17, 2020
Member
julienschmidt
left a comment
There was a problem hiding this comment.
Thanks!
LGTM. Waiting for Travis CI.
dolmen
reviewed
May 22, 2020
| if loc == time.UTC { | ||
| return time.Parse(timeFormat[:len(str)], str) | ||
| } | ||
| return time.ParseInLocation(timeFormat[:len(str)], str, loc) |
Contributor
There was a problem hiding this comment.
@chanxuehong Why not use ParseInLocation in all cases?
5 tasks
tz70s
pushed a commit
to tz70s/mysql
that referenced
this pull request
Sep 5, 2020
tz70s
pushed a commit
to tz70s/mysql
that referenced
this pull request
Sep 5, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please explain the changes you made here.
for now, if loc is not nil, will call t.Date and t.Clock, this PR saves these costs
Benchmark_parseDateTime
Benchmark_parseDateTime-8 4921956 238 ns/op
Benchmark_parseDateTimeOld
Benchmark_parseDateTimeOld-8 3827149 319 ns/op
Checklist