Skip to content

Commit 3c61332

Browse files
committed
Merge branch 'add-timing-to-make' of https://github.com/alanJoshiGeorge/arcade into development
2 parents 94df796 + d25be0d commit 3c61332

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

make.py

Lines changed: 14 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,24 @@ 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.perf_counter()
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+
155+
elapsed_time = time.perf_counter() - start_time
156+
h, rem = divmod(elapsed_time, 3600)
157+
m, s = divmod(rem, 60)
158+
159+
time_str = " ".join(part for part in [
160+
f"{int(h)}h" if h >= 1 else "",
161+
f"{int(m)}m" if m >= 1 or h >= 1 else "",
162+
f"{int(s)}s"
163+
] if part)
164+
165+
print(f">> Command finished ({time_str}): {cmd} \n")
154166

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

0 commit comments

Comments
 (0)