-
-
Save ndamclean/2c1113ea40199be7edd43a506748ffd7 to your computer and use it in GitHub Desktop.
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
import ciso8601 | |
import iso8601 | |
import pytest | |
from datetime import datetime | |
from dateutil import parser | |
TIME_STR = '2019-08-28T14:34:25.518993+00:00' | |
TIME_STR_Z = '2019-08-28T14:34:25.518993Z' | |
@pytest.mark.parametrize('iso_timestamp', [TIME_STR, TIME_STR_Z]) | |
def test_dateutil_isoparse(benchmark, iso_timestamp): | |
benchmark(parser.isoparse, iso_timestamp) | |
@pytest.mark.parametrize('iso_timestamp', [TIME_STR, TIME_STR_Z]) | |
def test_ciso8601_parse_datetime(benchmark, iso_timestamp): | |
benchmark(ciso8601.parse_datetime, iso_timestamp) | |
@pytest.mark.parametrize('iso_timestamp', [TIME_STR, TIME_STR_Z]) | |
def test_iso8601_parse_date(benchmark, iso_timestamp): | |
benchmark(iso8601.parse_date, iso_timestamp) | |
@pytest.mark.parametrize('iso_timestamp', [TIME_STR]) | |
def test_datetime_fromisoformat(benchmark, iso_timestamp): | |
benchmark(datetime.fromisoformat, iso_timestamp) | |
@pytest.mark.parametrize('iso_timestamp', [TIME_STR_Z]) | |
def test_datetime_fromisoformat_replace_z(benchmark, iso_timestamp): | |
def native_iso_parse(x): | |
return datetime.fromisoformat(x.replace('Z', '+00:00')) | |
benchmark(native_iso_parse, iso_timestamp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment