Skip to content
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

Performance vs. built-in time.strptime #5

Open
derekenos opened this issue Dec 29, 2020 · 0 comments
Open

Performance vs. built-in time.strptime #5

derekenos opened this issue Dec 29, 2020 · 0 comments

Comments

@derekenos
Copy link
Owner

derekenos commented Dec 29, 2020

Outputs

This Library

python3.9 -c "from __init__ import strptime; print(strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ'))"

Outputs

struct_time(tm_year=2020, tm_mon=12, tm_mday=28, tm_hour=12, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=363)

Built-in

python3.9 -c "from time import strptime; print(strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ'))"

Outputs

time.struct_time(tm_year=2020, tm_mon=12, tm_mday=28, tm_hour=12, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=363, tm_isdst=-1)

1000 executions

Python 2.7

This Library

$ time for i in {0..1000}; do python -c "from __init__ import strptime; strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ')"; done

real	0m10.061s
user	0m7.183s
sys	0m2.957s

Built-in

$ time for i in {0..1000}; do python -c "from time import strptime; strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ')"; done

real	0m11.979s
user	0m9.452s
sys	0m2.610s

Python 3.9

This Library

$ time for i in {0..1000}; do python3.9 -c "from __init__ import strptime; strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ')"; done

real	0m15.709s
user	0m12.771s
sys	0m3.033s

Built-in

$ time for i in {0..1000}; do python3.9 -c "from time import strptime; strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ')"; done

real	0m24.300s
user	0m20.659s
sys	0m3.734s

10,000 executions

Python 2.7

This Library

$ time for i in {0..10000}; do python -c "from time import strptime; strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ')"; done

real	1m58.888s
user	1m29.695s
sys	0m30.012s

Built-in

$ time for i in {0..10000}; do python -c "from __init__ import strptime; strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ')"; done

real	1m44.281s
user	1m15.622s
sys	0m29.298s

Python 3.9

This Library

$ time for i in {0..10000}; do python3.9 -c "from __init__ import strptime; strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ')"; done

real	2m36.523s
user	2m7.484s
sys	0m30.014s

Built-in

$ time for i in {0..10000}; do python3.9 -c "from time import strptime; strptime('2020-12-28T12:00:00Z', '%Y-%m-%dT%H:%M:%SZ')"; done

real	4m0.683s
user	3m25.811s
sys	0m35.859s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant