File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 88import time
99from typing import Any , Dict , List
1010
11- from core import GlobalStateManager , TokenStats
11+ from engine . core import GlobalStateManager
1212
1313from utils .logger import logger
1414
@@ -52,7 +52,29 @@ def get_final_stats(self) -> Dict[str, Any]:
5252 start_time = self .global_state .start_time
5353 end_time = time .time ()
5454
55- execution_time = max (end_time - start_time , 0.001 ) if start_time else 60.0
55+ # Calculate execution time with fallback strategy
56+ execution_time = 0.0
57+ if start_time :
58+ # Priority 1: Use start_time to calculate actual execution time
59+ execution_time = max (end_time - start_time , 0.001 )
60+ else :
61+ # Priority 2: Use task.duration as fallback
62+ try :
63+ duration = self .global_state .config .duration
64+ if duration and duration > 0 :
65+ execution_time = float (duration )
66+ else :
67+ # Both start_time and duration are invalid
68+ execution_time = 0.0
69+ self .task_logger .error (
70+ "Failed to calculate execution_time: both start_time and task.duration are invalid"
71+ )
72+ except Exception as e :
73+ # Exception occurred while getting duration
74+ execution_time = 0.0
75+ self .task_logger .error (
76+ f"Failed to calculate execution_time: start_time is invalid and error getting task.duration: { e } "
77+ )
5678
5779 return {
5880 "reqs_count" : stats .reqs_count ,
You can’t perform that action at this time.
0 commit comments