Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
output compilation time for each sketch
  • Loading branch information
2bndy5 committed Apr 18, 2022
commit 804a8524a0cc7534c1f450736dcd14cfc360753f
12 changes: 11 additions & 1 deletion compilesketches/compilesketches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import atexit
import time
import contextlib
import enum
import json
Expand Down Expand Up @@ -893,13 +894,22 @@ def compile_sketch(self, sketch_path, clean_build_cache):
if clean_build_cache:
for cache_path in pathlib.Path("/tmp").glob(pattern="arduino*"):
shutil.rmtree(path=cache_path)

start_time = time.monotonic()
compilation_data = self.run_arduino_cli_command(
command=compilation_command, enable_output=self.RunCommandOutput.NONE, exit_on_failure=False)
diff_time = time.monotonic() - start_time
time_summary = ""
if diff_time > 60:
if diff_time > 360:
time_summary += f"{int(diff_time / 360)} hours "
time_summary += f"{int(diff_time / 60) % 60} minutes "
time_summary += f"{int(diff_time) % 60} seconds."

# Group compilation output to make the log easy to read
# https://github.com/actions/toolkit/blob/master/docs/commands.md#group-and-ungroup-log-lines
print("::group::Compiling sketch:", path_relative_to_workspace(path=sketch_path))
print(compilation_data.stdout)
print("Compilation time elapsed", time_summary)
print("::endgroup::")

class CompilationResult:
Expand Down