Skip to content
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion tests/benchmarks/test_serialization_micro.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def r():
s.to_json(m_big)


@pytest.mark.benchmark(group='model-list-json')
@pytest.mark.benchmark(group='temporal')
def test_datetime(benchmark):
v = SchemaSerializer(core_schema.datetime_schema())
d = datetime(2022, 12, 2, 12, 13, 14)
Expand All @@ -360,6 +360,33 @@ def r():
v.to_python(d, mode='json')


@pytest.mark.benchmark(group='temporal')
def test_datetime_seconds(benchmark):
v = SchemaSerializer(
core_schema.datetime_schema(),
config={
'ser_json_temporal': 'seconds',
},
)
d = datetime(2022, 12, 2, 12, 13, 14)
assert v.to_python(d, mode='json') == 1669983194.0

@benchmark
def r():
v.to_python(d, mode='json')


@pytest.mark.benchmark(group='temporal')
def test_datetime_milliseconds(benchmark):
v = SchemaSerializer(core_schema.datetime_schema(), config={'ser_json_temporal': 'milliseconds'})
d = datetime(2022, 12, 2, 12, 13, 14)
assert v.to_python(d, mode='json') == 1669983194000.0

@benchmark
def r():
v.to_python(d, mode='json')


@pytest.mark.benchmark(group='model-list-json')
def test_uuid(benchmark):
v = SchemaSerializer(core_schema.uuid_schema())
Expand Down
Loading