Skip to content

Commit 993a2b6

Browse files
Add timing output to subprocess commands in make.py
1 parent 4d8c653 commit 993a2b6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

make.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from shutil import rmtree, which
2020
from typing import Union
2121
from collections.abc import Generator
22+
import time
2223

2324
PathLike = Union[Path, str, bytes]
2425

@@ -144,13 +145,15 @@ def run(args: str | list[str], cd: PathLike | None = None) -> None:
144145
"""
145146
cmd = " ".join(args)
146147
print(">> Running command:", cmd)
148+
start_time = time.time()
147149
if cd is not None:
148150
with cd_context(_resolve(cd, strict=True)):
149151
result = subprocess.run(args)
150152
else:
151153
result = subprocess.run(args)
152-
153-
print(">> Command finished:", cmd, "\n")
154+
elapsed_time = time.time() - start_time
155+
minutes, seconds = divmod(elapsed_time, 60)
156+
print(f">> Command finished ({int(minutes)}m {int(seconds)}s): {cmd} \n")
154157

155158
# TODO: Should we exit here? Or continue to let other commands run also?
156159
if result.returncode != 0:

0 commit comments

Comments
 (0)