Skip to content

Commit e2f76c9

Browse files
committed
[NFC] Print build-script timings to stderr
1 parent 1ee12c5 commit e2f76c9

File tree

1 file changed

+11
-8
lines changed
  • utils/swift_build_support/swift_build_support

1 file changed

+11
-8
lines changed

utils/swift_build_support/swift_build_support/utils.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ def log_analyzer():
7575
Analyze .build_script_log and provide a summary of the time execution.
7676
"""
7777
build_script_log_path = log_time_path()
78-
print("--- Build Script Analyzer ---")
78+
print("--- Build Script Analyzer ---", file=sys.stderr)
7979
build_events = []
8080
total_duration = 0
8181
if os.path.exists(build_script_log_path):
82-
print("Build Script Log: {}".format(build_script_log_path))
82+
print("Build Script Log: {}".format(build_script_log_path), file=sys.stderr)
8383
with open(build_script_log_path) as f:
8484
for event in f:
8585
build_event = json.loads(event)
@@ -89,15 +89,17 @@ def log_analyzer():
8989
finish_events = [x for x in build_events if x["event"] == "end"]
9090
finish_events.sort(key=lambda x: x["duration"], reverse=True)
9191

92-
print("Build Percentage \t Build Duration (sec) \t Build Phase")
93-
print("================ \t ==================== \t ===========")
92+
print("Build Percentage \t Build Duration (sec) \t Build Phase",
93+
file=sys.stderr)
94+
print("================ \t ==================== \t ===========",
95+
file=sys.stderr)
9496
event_row = '{:<17.1%} \t {:<21} \t {}'
9597
for build_event in finish_events:
9698
duration_percentage = \
9799
(float(build_event["duration"]) / float(total_duration))
98100
print(event_row.format(duration_percentage,
99101
build_event["duration"],
100-
build_event["command"]))
102+
build_event["command"]), file=sys.stderr)
101103

102104
hours, remainder = divmod(total_duration, 3600)
103105
minutes, seconds = divmod(remainder, 60)
@@ -111,7 +113,8 @@ def log_analyzer():
111113
formatted_duration = ""
112114

113115
print("Total Duration: {:.2f} seconds".format(
114-
total_duration) + formatted_duration)
116+
total_duration) + formatted_duration, file=sys.stderr)
115117
else:
116-
print("Skip build script analyzer")
117-
print(".build_script_log file not found at {}".format(build_script_log_path))
118+
print("Skip build script analyzer", file=sys.stderr)
119+
print(".build_script_log file not found at {}".format(build_script_log_path),
120+
file=sys.stderr)

0 commit comments

Comments
 (0)