@@ -148,12 +148,39 @@ def test_collect_trial_metrics_returns_node_snapshot():
148148 metrics .record (EventTypes .EG_FAILURE , "e0" , fidelity = 0.8 )
149149 metrics .record (EventTypes .EG_SUCCESS , "e0" , fidelity = 0.8 )
150150
151- trial = metrics .collect_trial_metrics ("e0" , throughput = 12.5 )
151+ trial = metrics .collect_trial_metrics ("e0" )
152152
153153 assert trial ["eg_failures" ] == 1
154154 assert trial ["eg_success" ] == 1
155155 assert trial ["eg_success_rate" ] == 0.5
156- assert trial ["app_throughput" ] == 12.5
156+ assert math .isnan (trial ["app_throughput" ])
157+
158+
159+ def test_collect_trial_metrics_computes_throughput_from_deliveries ():
160+ timeline = Timeline (int (1e12 ))
161+ timeline .time = int (1e12 )
162+ metrics .register_time_provider (timeline )
163+ metrics .enable ([EventTypes .DELIVERY ])
164+
165+ metrics .record (
166+ EventTypes .DELIVERY ,
167+ "right" ,
168+ fidelity = 0.9 ,
169+ pair_number = 1 ,
170+ start_time = int (1e12 ),
171+ )
172+ timeline .time = int (2e12 )
173+ metrics .record (
174+ EventTypes .DELIVERY ,
175+ "right" ,
176+ fidelity = 0.9 ,
177+ pair_number = 2 ,
178+ start_time = int (1e12 ),
179+ )
180+
181+ trial = metrics .collect_trial_metrics ("left" , delivery_owner = "right" )
182+
183+ assert trial ["app_throughput" ] == pytest .approx (2.0 )
157184
158185
159186def test_collect_trial_metrics_without_throughput_is_nan ():
@@ -313,6 +340,7 @@ def now(self) -> int:
313340 assert trial ["ep_success" ] == 2
314341 assert trial ["purified_fidelities" ] == [0.7 , 0.75 ]
315342 assert trial ["delivery_time" ] == pytest .approx (0.4 )
343+ assert trial ["app_throughput" ] == pytest .approx (7.5 )
316344
317345
318346def test_collect_trial_metrics_delivery_time_nan_when_target_not_reached ():
@@ -330,7 +358,13 @@ def test_collect_trial_metrics_delivery_time_nan_when_target_not_reached():
330358
331359def test_collect_trial_metrics_delivery_owner_defaults_to_owner ():
332360 metrics .enable ([EventTypes .DELIVERY ])
333- metrics .record (EventTypes .DELIVERY , "right" , fidelity = 0.9 , pair_number = 1 )
361+ metrics .record (
362+ EventTypes .DELIVERY ,
363+ "right" ,
364+ fidelity = 0.9 ,
365+ pair_number = 1 ,
366+ start_time = 0 ,
367+ )
334368
335369 trial = metrics .collect_trial_metrics (
336370 "right" ,
0 commit comments