Module: Hone::Formatters::Filterable

Included in:
Base, Reporter
Defined in:
lib/hone/formatters/filterable.rb

Constant Summary collapse

PRIORITY_LABELS =
{
  hot_cpu: "HOT-CPU",
  hot_alloc: "HOT-ALLOC",
  jit_unfriendly: "JIT-UNFRIENDLY",
  warm: "WARM",
  cold: "COLD",
  unknown: "?"
}.freeze

Instance Method Summary collapse

Instance Method Details

#filter_cold(findings, show_cold:) ⇒ Object



15
16
17
18
19
# File 'lib/hone/formatters/filterable.rb', line 15

def filter_cold(findings, show_cold:)
  return findings if show_cold

  findings.reject { |f| f.priority == :cold }
end

#format_percent(value) ⇒ Object



25
26
27
28
# File 'lib/hone/formatters/filterable.rb', line 25

def format_percent(value)
  return "" if value.nil?
  "%.1f%%" % value
end

#priority_label(priority) ⇒ Object



21
22
23
# File 'lib/hone/formatters/filterable.rb', line 21

def priority_label(priority)
  PRIORITY_LABELS.fetch(priority, priority.to_s.upcase)
end