From 993a2b6b762652bf691715fe7018aaed869358cf Mon Sep 17 00:00:00 2001 From: Alan Joshi George Date: Tue, 10 Jun 2025 17:35:17 +0530 Subject: [PATCH 1/2] Add timing output to subprocess commands in make.py --- make.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/make.py b/make.py index 463de5daf0..d268e41b94 100755 --- a/make.py +++ b/make.py @@ -19,6 +19,7 @@ from shutil import rmtree, which from typing import Union from collections.abc import Generator +import time PathLike = Union[Path, str, bytes] @@ -144,13 +145,15 @@ def run(args: str | list[str], cd: PathLike | None = None) -> None: """ cmd = " ".join(args) print(">> Running command:", cmd) + start_time = time.time() if cd is not None: with cd_context(_resolve(cd, strict=True)): result = subprocess.run(args) else: result = subprocess.run(args) - - print(">> Command finished:", cmd, "\n") + elapsed_time = time.time() - start_time + minutes, seconds = divmod(elapsed_time, 60) + print(f">> Command finished ({int(minutes)}m {int(seconds)}s): {cmd} \n") # TODO: Should we exit here? Or continue to let other commands run also? if result.returncode != 0: From d25be0dc31a3783eb839cb46750d8c3f3cc1fe99 Mon Sep 17 00:00:00 2001 From: Alan Joshi George Date: Sun, 15 Jun 2025 13:41:39 +0530 Subject: [PATCH 2/2] update time reporting for subprocess commands --- make.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/make.py b/make.py index d268e41b94..e6ae8a354e 100755 --- a/make.py +++ b/make.py @@ -145,15 +145,24 @@ def run(args: str | list[str], cd: PathLike | None = None) -> None: """ cmd = " ".join(args) print(">> Running command:", cmd) - start_time = time.time() + start_time = time.perf_counter() if cd is not None: with cd_context(_resolve(cd, strict=True)): result = subprocess.run(args) else: result = subprocess.run(args) - elapsed_time = time.time() - start_time - minutes, seconds = divmod(elapsed_time, 60) - print(f">> Command finished ({int(minutes)}m {int(seconds)}s): {cmd} \n") + + elapsed_time = time.perf_counter() - start_time + h, rem = divmod(elapsed_time, 3600) + m, s = divmod(rem, 60) + + time_str = " ".join(part for part in [ + f"{int(h)}h" if h >= 1 else "", + f"{int(m)}m" if m >= 1 or h >= 1 else "", + f"{int(s)}s" + ] if part) + + print(f">> Command finished ({time_str}): {cmd} \n") # TODO: Should we exit here? Or continue to let other commands run also? if result.returncode != 0: