class Carver::Presenter
Constants
- BYTES_TO_MB_CONSTANT
Public Class Methods
new(results, path, action, parent)
click to toggle source
# File lib/carver/presenter.rb, line 6 def initialize(results, path, action, parent) @results = results @path = path @action = action @parent = parent end
Public Instance Methods
add_to_results()
click to toggle source
# File lib/carver/presenter.rb, line 20 def add_to_results Carver.add_to_results( entry_info[:name], { total_allocated_memsize: allocated_memory, total_retained_memsize: retained_memory }.freeze ) end
log()
click to toggle source
# File lib/carver/presenter.rb, line 13 def log Rails.logger.info( "[Carver] source=#{entry_info[:name]} type=#{entry_info[:type]} total_allocated_memsize=#{allocated_memory} " \ "total_retained_memsize=#{retained_memory}" ) end
Private Instance Methods
allocated_memory()
click to toggle source
# File lib/carver/presenter.rb, line 29 def allocated_memory (@results.total_allocated_memsize.to_f / BYTES_TO_MB_CONSTANT).round(5) end
entry()
click to toggle source
# File lib/carver/presenter.rb, line 45 def entry if is_controller? { name: "#{@path.split('/').map(&:titleize).join('::').delete(' ')}Controller##{@action}", type: 'controller' }.freeze else { name: "#{@path}##{@action}", type: 'job' }.freeze end end
entry_info()
click to toggle source
# File lib/carver/presenter.rb, line 41 def entry_info @entry ||= entry end
is_controller?()
click to toggle source
# File lib/carver/presenter.rb, line 37 def is_controller? @parent.downcase.include?('controller') end
retained_memory()
click to toggle source
# File lib/carver/presenter.rb, line 33 def retained_memory (@results.total_retained_memsize.to_f / BYTES_TO_MB_CONSTANT).round(5) end