@@ -71,9 +71,7 @@ def serialize_other(obj, mapped):
7171if __name__ == "__main__" :
7272 parser = argparse .ArgumentParser ()
7373 parser .add_argument ("-n" , "--number" , type = int , default = 25 , help = "Number of runs" )
74- parser .add_argument (
75- "-m" , "--mapped" , action = "store_true" , help = "Use memory mapping"
76- )
74+ parser .add_argument ("-m" , "--mapped" , action = "store_true" , help = "Use memory mapping" )
7775 args = parser .parse_args ()
7876
7977 _globals = {
@@ -99,22 +97,10 @@ def serialize_other(obj, mapped):
9997 print (f"stream: { t_stream :.6f} s total, { t_stream / args .number :.6f} s per call" )
10098 print (f"other: { t_other :.6f} s total, { t_other / args .number :.6f} s per call" )
10199
102- t_main_s = timeit .timeit (
103- "main(obj, mapped)" , number = args .number , globals = _serialize
104- )
105- t_stream_s = timeit .timeit (
106- "stream(obj, mapped)" , number = args .number , globals = _serialize
107- )
108- t_other_s = timeit .timeit (
109- "other(obj, mapped)" , number = args .number , globals = _serialize
110- )
111-
112- print (
113- f"main serialize: { t_main_s :.6f} s total, { t_main_s / args .number :.6f} s per call"
114- )
115- print (
116- f"stream serialize: { t_stream_s :.6f} s total, { t_stream_s / args .number :.6f} s per call"
117- )
118- print (
119- f"other serialize: { t_other_s :.6f} s total, { t_other_s / args .number :.6f} s per call"
120- )
100+ t_main_s = timeit .timeit ("main(obj, mapped)" , number = args .number , globals = _serialize )
101+ t_stream_s = timeit .timeit ("stream(obj, mapped)" , number = args .number , globals = _serialize )
102+ t_other_s = timeit .timeit ("other(obj, mapped)" , number = args .number , globals = _serialize )
103+
104+ print (f"main serialize: { t_main_s :.6f} s total, { t_main_s / args .number :.6f} s per call" )
105+ print (f"stream serialize: { t_stream_s :.6f} s total, { t_stream_s / args .number :.6f} s per call" )
106+ print (f"other serialize: { t_other_s :.6f} s total, { t_other_s / args .number :.6f} s per call" )
0 commit comments