Skip to content

Commit 99033c0

Browse files
committed
output sompilation time for each sketch
1 parent a570356 commit 99033c0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

compilesketches/compilesketches.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import atexit
2+
import time
23
import contextlib
34
import enum
45
import json
@@ -893,13 +894,22 @@ def compile_sketch(self, sketch_path, clean_build_cache):
893894
if clean_build_cache:
894895
for cache_path in pathlib.Path("/tmp").glob(pattern="arduino*"):
895896
shutil.rmtree(path=cache_path)
896-
897+
start_time = time.monotonic()
897898
compilation_data = self.run_arduino_cli_command(
898899
command=compilation_command, enable_output=self.RunCommandOutput.NONE, exit_on_failure=False)
900+
diff_time = time.monotonic() - start_time
901+
time_summary = ""
902+
if diff_time > 60:
903+
if diff_time > 360:
904+
time_summary += f"{int(diff_time / 360)} hours "
905+
time_summary += f"{int(diff_time / 60) % 60} minutes "
906+
time_summary += f"{int(diff_time) % 60} seconds."
907+
899908
# Group compilation output to make the log easy to read
900909
# https://github.com/actions/toolkit/blob/master/docs/commands.md#group-and-ungroup-log-lines
901910
print("::group::Compiling sketch:", path_relative_to_workspace(path=sketch_path))
902911
print(compilation_data.stdout)
912+
print("Compilation time elapsed", time_summary)
903913
print("::endgroup::")
904914

905915
class CompilationResult:

0 commit comments

Comments
 (0)