File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,19 +103,36 @@ def merge_execution_stats(
103103 if first_stats is None :
104104 return second_stats .copy ()
105105
106+ def safe_sum (x , y ):
107+ if x is None :
108+ return y
109+ elif y is None :
110+ return x
111+ else :
112+ return x + y
113+
114+ def safe_max (x , y ):
115+ if x is None :
116+ return y
117+ elif y is None :
118+ return x
119+ else :
120+ return max (x , y )
121+
106122 ret = first_stats .copy ()
107123 ret ["execution_time" ] += second_stats ["execution_time" ]
108124
109125 if concurrent :
110126 ret ["execution_wall_clock_time" ] = max (
111127 ret ["execution_wall_clock_time" ],
112128 second_stats ["execution_wall_clock_time" ])
113- ret ["execution_memory" ] += second_stats ["execution_memory" ]
129+ ret ["execution_memory" ] = safe_sum (ret ["execution_memory" ],
130+ second_stats ["execution_memory" ])
114131 else :
115132 ret ["execution_wall_clock_time" ] += \
116133 second_stats ["execution_wall_clock_time" ]
117- ret ["execution_memory" ] = max (ret ["execution_memory" ],
118- second_stats ["execution_memory" ])
134+ ret ["execution_memory" ] = safe_max (ret ["execution_memory" ],
135+ second_stats ["execution_memory" ])
119136
120137 if first_stats ["exit_status" ] == Sandbox .EXIT_OK :
121138 ret ["exit_status" ] = second_stats ["exit_status" ]
You can’t perform that action at this time.
0 commit comments