Module: RailsMemoryProfiler::Notifiers

Defined in:
lib/rails_memory_profiler/notifiers.rb,
lib/rails_memory_profiler/notifiers/logger.rb,
lib/rails_memory_profiler/notifiers/stdout.rb,
lib/rails_memory_profiler/notifiers/console.rb,
lib/rails_memory_profiler/notifiers/file_logger.rb

Defined Under Namespace

Classes: Console, FileLogger, Logger, Stdout

Class Method Summary collapse

Class Method Details

.format_line(report) ⇒ Object



8
9
10
11
12
13
# File 'lib/rails_memory_profiler/notifiers.rb', line 8

def self.format_line(report)
  action = [report[:controller], report[:action]].compact.join("#")
  "[RailsMemoryProfiler] #{report[:method]} #{report[:path]} (#{action})" \
    "#{thousands(report[:allocated_objects])} allocated," \
    " #{report[:retained_objects]} retained, #{report[:duration_ms]}ms"
end

.thousands(n) ⇒ Object



15
16
17
# File 'lib/rails_memory_profiler/notifiers.rb', line 15

def self.thousands(n)
  n.to_s.reverse.scan(/\d{1,3}/).join(",").reverse
end