From 44e169efe2fde332faf656d23ed727928597063c Mon Sep 17 00:00:00 2001 From: Harsh Kumar Date: Mon, 2 Mar 2026 22:49:21 +0530 Subject: [PATCH 1/3] Add numeric elapsed_seconds to metrics JSON Resolves #2506 genMetrics.py stores stage runtimes as human-readable strings (e.g., "0:04.26") which are hard to consume programmatically. This adds numeric elapsed_seconds fields (in seconds as floats) alongside the existing string fields so runtimes are directly usable for analysis and plotting. New fields added per stage: - __elapsed_seconds (float, seconds) - total_elapsed_seconds (float, seconds) Existing fields (runtime__total, total_time) are unchanged. Signed-off-by: Harsh Kumar Patwa Signed-off-by: Harsh Kumar --- flow/util/genMetrics.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flow/util/genMetrics.py b/flow/util/genMetrics.py index 6090714532..e8b0cbcd67 100755 --- a/flow/util/genMetrics.py +++ b/flow/util/genMetrics.py @@ -315,6 +315,7 @@ def extract_metrics( failed = False total = timedelta() + elapsed_seconds = {} for key in metrics_dict: if key.endswith("__runtime__total"): # Big try block because Hour and microsecond is optional @@ -341,10 +342,16 @@ def extract_metrics( ) total += delta + stage = key.removesuffix("__runtime__total") + elapsed_seconds[stage + "__elapsed_seconds"] = delta.total_seconds() + if failed: metrics_dict["total_time"] = "ERR" else: metrics_dict["total_time"] = str(total) + metrics_dict["total_elapsed_seconds"] = total.total_seconds() + + metrics_dict.update(elapsed_seconds) metrics_dict = { key.replace(":", "__"): value for key, value in metrics_dict.items() From ade94d072dd12fe741fb3c74ba22f2af97b1d01e Mon Sep 17 00:00:00 2001 From: Harsh Kumar Date: Mon, 2 Mar 2026 23:48:08 +0530 Subject: [PATCH 2/3] Set total_elapsed_seconds to ERR on parse failure Address review feedback: add total_elapsed_seconds = "ERR" in the failed parsing case for consistency with total_time. Signed-off-by: Harsh Kumar Patwa Signed-off-by: Harsh Kumar --- flow/util/genMetrics.py | 1 + 1 file changed, 1 insertion(+) diff --git a/flow/util/genMetrics.py b/flow/util/genMetrics.py index e8b0cbcd67..9c7966ee9a 100755 --- a/flow/util/genMetrics.py +++ b/flow/util/genMetrics.py @@ -347,6 +347,7 @@ def extract_metrics( if failed: metrics_dict["total_time"] = "ERR" + metrics_dict["total_elapsed_seconds"] = "ERR" else: metrics_dict["total_time"] = str(total) metrics_dict["total_elapsed_seconds"] = total.total_seconds() From ae7ef79681e87b4a6ef12e12b65d21d6f6732eb0 Mon Sep 17 00:00:00 2001 From: Harsh Kumar Date: Tue, 3 Mar 2026 02:00:21 +0530 Subject: [PATCH 3/3] Fix Python 3.8 compatibility: replace removesuffix with slice str.removesuffix() requires Python 3.9+. Replace with a string slice to maintain compatibility with older Python versions used in CI. Signed-off-by: Harsh Kumar Patwa Signed-off-by: Harsh Kumar --- flow/util/genMetrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flow/util/genMetrics.py b/flow/util/genMetrics.py index 9c7966ee9a..fbf746cdfc 100755 --- a/flow/util/genMetrics.py +++ b/flow/util/genMetrics.py @@ -342,7 +342,7 @@ def extract_metrics( ) total += delta - stage = key.removesuffix("__runtime__total") + stage = key[: -len("__runtime__total")] elapsed_seconds[stage + "__elapsed_seconds"] = delta.total_seconds() if failed: