Module: Pod::PodGenerate::Benchmark::Profiler
- Defined in:
- lib/cocoapods-podgenerate/benchmark/profiler.rb
Defined Under Namespace
Modules: ProfilerHooks, ProfilerSubSteps
Class Method Summary
collapse
Class Method Details
.enable! ⇒ Object
19
20
21
|
# File 'lib/cocoapods-podgenerate/benchmark/profiler.rb', line 19
def enable!
@enabled = true
end
|
.enabled? ⇒ Boolean
14
15
16
17
|
# File 'lib/cocoapods-podgenerate/benchmark/profiler.rb', line 14
def enabled?
@enabled ||= ENV['POD_GENERATE_DEBUG'] == '1' ||
ENV['COCOAPODS_PODGENERATE_DEBUG'] == '1'
end
|
.install ⇒ Object
23
24
25
26
27
|
# File 'lib/cocoapods-podgenerate/benchmark/profiler.rb', line 23
def install
return unless enabled?
Pod::Installer.prepend(ProfilerHooks)
Pod::Installer.prepend(ProfilerSubSteps)
end
|
.record_phase(name, duration) ⇒ Object
29
30
31
|
# File 'lib/cocoapods-podgenerate/benchmark/profiler.rb', line 29
def record_phase(name, duration)
@phase_timings << [name, duration]
end
|
.report ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/cocoapods-podgenerate/benchmark/profiler.rb', line 33
def report
return if @phase_timings.empty?
total = @phase_timings.map(&:last).sum
Pod::UI.puts "\n[cocoapods-podgenerate] Performance Report:"
@phase_timings.each do |name, dur|
pct = total > 0 ? (dur / total * 100) : 0
Pod::UI.puts " #{format('%-35s', name)} #{format('%.2f', dur)}s (#{format('%.1f', pct)}%)"
end
Pod::UI.puts " #{'─' * 50}"
Pod::UI.puts " #{format('%-35s', 'TOTAL')} #{format('%.2f', total)}s"
@phase_timings.clear
end
|