Module: HeapProfiler

Defined in:
lib/heap_profiler/cli.rb,
lib/heap_profiler/diff.rb,
lib/heap_profiler/dump.rb,
lib/heap_profiler/index.rb,
lib/heap_profiler/parser.rb,
lib/heap_profiler/results.rb,
lib/heap_profiler/runtime.rb,
lib/heap_profiler/version.rb,
lib/heap_profiler/analyzer.rb,
lib/heap_profiler/reporter.rb,
lib/heap_profiler/monochrome.rb,
lib/heap_profiler/polychrome.rb

Defined Under Namespace

Modules: Monochrome, Parser, Polychrome Classes: AbstractResults, Analyzer, CLI, Diff, DiffResults, Dump, HeapResults, Index, Reporter

Constant Summary collapse

Error =
Class.new(StandardError)
CapacityError =
Class.new(Error)
VERSION =
"0.7.0"

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.current_reporterObject

Returns the value of attribute current_reporter.



14
15
16
# File 'lib/heap_profiler/runtime.rb', line 14

def current_reporter
  @current_reporter
end

Class Method Details

.report(dir, &block) ⇒ Object



26
27
28
# File 'lib/heap_profiler/runtime.rb', line 26

def report(dir, &block)
  Reporter.new(dir).run(&block)
end

.start(dir, **kwargs) ⇒ Object



16
17
18
19
20
# File 'lib/heap_profiler/runtime.rb', line 16

def start(dir, **kwargs)
  return if current_reporter
  self.current_reporter = Reporter.new(dir)
  current_reporter.start(**kwargs)
end

.stopObject



22
23
24
# File 'lib/heap_profiler/runtime.rb', line 22

def stop
  current_reporter&.stop
end

Instance Method Details

#name_anonymous_modules!Object



13
14
15
16
17
18
19
20
21
# File 'lib/heap_profiler/reporter.rb', line 13

def name_anonymous_modules!
  ObjectSpace.each_object(Module) do |mod|
    next if mod.singleton_class?
    next if real_mod_name(mod)
    # We have to assign it at the top level to avoid allocating a string for the name
    ::Object.const_set(:AnonymousClassOrModule, mod)
    ::Object.send(:remove_const, :AnonymousClassOrModule)
  end
end

#real_mod_name(mod) ⇒ Object



24
25
26
# File 'lib/heap_profiler/reporter.rb', line 24

def real_mod_name(mod)
  mod.__real_mod_name
end