-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
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
Speedup parsing of datetime fieldtypes initialization by string #87
Merged
Conversation
This file contains 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
Codecov Report
@@ Coverage Diff @@
## main #87 +/- ##
==========================================
+ Coverage 79.22% 79.27% +0.04%
==========================================
Files 32 32
Lines 2932 2939 +7
==========================================
+ Hits 2323 2330 +7
Misses 609 609
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Benchmark scriptBenchmarked using the following script. #!/bin/sh -x
# default datetime str without any TZ data
python3 -m timeit -n 100000 "from flow.record.fieldtypes import datetime" 'datetime("2023-09-04T13:33:37")'
# default isoformat(), this is how it's serialized in msgpack for tz aware datetime objects
python3 -m timeit -n 100000 "from flow.record.fieldtypes import datetime" 'datetime("2023-09-04T13:33:37+03:00")'
# RFC3339Nano, 2006-01-02T15:04:05.999999999, used by Docker
python3 -m timeit -n 100000 "from flow.record.fieldtypes import datetime" 'datetime("2023-09-04T13:33:37.123456789999999")'
python3 -m timeit -n 100000 "from flow.record.fieldtypes import datetime" 'datetime("2023-09-04T13:33:37.123456789999999-02:00")'
python3 -m timeit -n 100000 "from flow.record.fieldtypes import datetime" 'datetime("2023-09-04T13:33:37.123456789999999Z")'
# other variants, but less common
python3 -m timeit -n 100000 "from flow.record.fieldtypes import datetime" 'datetime("2023-09-04T13:33:37Z")'
python3 -m timeit -n 100000 "from flow.record.fieldtypes import datetime" 'datetime("2023-09-04T13:33:37.123456-02:00")'
python3 -m timeit -n 100000 "from flow.record.fieldtypes import datetime" 'datetime("2023-09-04T13:33:37.123456789+03:00")' Benchmark resultsPython 3.8
Python 3.9
Python 3.10
Python 3.11note, Python3.11 was already fast pathed previously.
|
yunzheng
force-pushed
the
improvement/datetime-fromisoformat
branch
from
October 16, 2023 08:45
26574bf
to
fdd571a
Compare
Schamper
requested changes
Oct 16, 2023
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Schamper
approved these changes
Oct 16, 2023
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.
This change mainly removes the use of expensive regexes and exception handling, improving the speed significantly.