@@ -349,7 +349,7 @@ def r():
349349 s .to_json (m_big )
350350
351351
352- @pytest .mark .benchmark (group = 'model-list-json ' )
352+ @pytest .mark .benchmark (group = 'temporal ' )
353353def test_datetime (benchmark ):
354354 v = SchemaSerializer (core_schema .datetime_schema ())
355355 d = datetime (2022 , 12 , 2 , 12 , 13 , 14 )
@@ -360,6 +360,33 @@ def r():
360360 v .to_python (d , mode = 'json' )
361361
362362
363+ @pytest .mark .benchmark (group = 'temporal' )
364+ def test_datetime_seconds (benchmark ):
365+ v = SchemaSerializer (
366+ core_schema .datetime_schema (),
367+ config = {
368+ 'ser_json_temporal' : 'seconds' ,
369+ },
370+ )
371+ d = datetime (2022 , 12 , 2 , 12 , 13 , 14 )
372+ assert v .to_python (d , mode = 'json' ) == 1669983194.0
373+
374+ @benchmark
375+ def r ():
376+ v .to_python (d , mode = 'json' )
377+
378+
379+ @pytest .mark .benchmark (group = 'temporal' )
380+ def test_datetime_milliseconds (benchmark ):
381+ v = SchemaSerializer (core_schema .datetime_schema (), config = {'ser_json_temporal' : 'milliseconds' })
382+ d = datetime (2022 , 12 , 2 , 12 , 13 , 14 )
383+ assert v .to_python (d , mode = 'json' ) == 1669983194000.0
384+
385+ @benchmark
386+ def r ():
387+ v .to_python (d , mode = 'json' )
388+
389+
363390@pytest .mark .benchmark (group = 'model-list-json' )
364391def test_uuid (benchmark ):
365392 v = SchemaSerializer (core_schema .uuid_schema ())
0 commit comments