Skip to content

Commit 0a375f5

Browse files
RX14asterite
authored andcommittedJun 4, 2017
Fix current-stage compiler stats output
Before be945b5, --stats output would print the current stage name while it was executing. This is useful for debugging compiler hangs and tracking the progress of the compiler without --progress. After that commit, the progress output would only print after the stage had fully completed, meaning you had to rely on --progress to track compiler progress. This patch fixes this regression by printing the stage name (with no times or memory figures) before the stage starts and resetting the cursor to the beginning of the line. If both --progress and --stats are specified, this pre-stage line isn't printed as it would just be overwritten by --progress output anyway.
1 parent 5af6fb7 commit 0a375f5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎src/compiler/crystal/progress_tracker.cr

+9-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Crystal
1515
def stage(name)
1616
@current_stage_name = name
1717

18+
print_stats
1819
print_progress
1920

2021
start_time = Time.now
@@ -37,13 +38,17 @@ module Crystal
3738
print "\r"
3839
end
3940

40-
def print_stats(time_taken)
41+
def print_stats(time_taken = nil)
4142
return unless @stats
4243

43-
memory_usage_mb = GC.stats.heap_size / 1024.0 / 1024.0
44-
memory_usage_str = " (%7.2fMB)" % {memory_usage_mb} if true # display_memory?
4544
justified_name = "#{current_stage_name}:".ljust(STAGE_PADDING)
46-
puts "#{justified_name} #{time_taken}#{memory_usage_str}"
45+
if time_taken
46+
memory_usage_mb = GC.stats.heap_size / 1024.0 / 1024.0
47+
memory_usage_str = " (%7.2fMB)" % {memory_usage_mb} if true # display_memory?
48+
puts "#{justified_name} #{time_taken}#{memory_usage_str}"
49+
else
50+
print "#{justified_name}\r" unless @progress
51+
end
4752
end
4853

4954
def print_progress

0 commit comments

Comments
 (0)
Please sign in to comment.