Class: ProfilerFormatter
- Inherits:
-
XCPretty::Formatter
- Object
- XCPretty::Formatter
- ProfilerFormatter
- Defined in:
- lib/profiler_formatter.rb
Instance Method Summary collapse
-
#format_compile(file_name, file_path) ⇒ Object
For each file that we compile, track the current timestamp.
- #format_compile_command(compiler_command, file_path) ⇒ Object
-
#format_linking(file, build_variant, arch) ⇒ Object
Every time we enter the linking phase, we wrap up a compilation phase Store statistics for the current phase and set up for a new phase.
-
#format_phase_success(phase_name) ⇒ Object
When the build succeeded, we can generate our statistics and print them to the console.
-
#initialize(use_unicode, colorize) ⇒ ProfilerFormatter
constructor
A new instance of ProfilerFormatter.
Constructor Details
#initialize(use_unicode, colorize) ⇒ ProfilerFormatter
Returns a new instance of ProfilerFormatter.
3 4 5 6 7 8 |
# File 'lib/profiler_formatter.rb', line 3 def initialize(use_unicode, colorize) super(use_unicode, colorize) @compilation_phases = [] @current_compilation_phase = [] @compilation_phase_end_times = [] end |
Instance Method Details
#format_compile(file_name, file_path) ⇒ Object
For each file that we compile, track the current timestamp
11 12 13 14 |
# File 'lib/profiler_formatter.rb', line 11 def format_compile(file_name, file_path) mark_compilation(file_path, file_name) EMPTY; end |
#format_compile_command(compiler_command, file_path) ⇒ Object
16 17 18 19 |
# File 'lib/profiler_formatter.rb', line 16 def format_compile_command(compiler_command, file_path) mark_compilation(file_path, nil) EMPTY; end |
#format_linking(file, build_variant, arch) ⇒ Object
Every time we enter the linking phase, we wrap up a compilation phase Store statistics for the current phase and set up for a new phase
23 24 25 26 |
# File 'lib/profiler_formatter.rb', line 23 def format_linking(file, build_variant, arch) start_new_compilation_phase EMPTY; end |
#format_phase_success(phase_name) ⇒ Object
When the build succeeded, we can generate our statistics and print them to the console
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/profiler_formatter.rb', line 29 def format_phase_success(phase_name) unless @current_compilation_phase.empty? start_new_compilation_phase end if phase_name == "BUILD" compile_times = calculate_compile_times compile_times.sort_by { | compilation | compilation[:compile_time] }.each do | compilation | puts "[#{format("%.4f", compilation[:compile_time])}] #{compilation[:file_path]}" end total_time = compile_times.reduce(0) { | acc, compilation | acc + compilation[:compile_time] } puts "-----" puts "[#{format("%.4f", total_time)}] Total compilation time" end EMPTY; end |