Class: NewRelic::Agent::StatsEngine::GCProfiler::Profiler

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/stats_engine/gc_profiler.rb

Direct Known Subclasses

RailsBench, Rubinius, Ruby19

Instance Method Summary collapse

Constructor Details

#initializeProfiler

Returns a new instance of Profiler.



22
23
24
25
26
27
# File 'lib/new_relic/agent/stats_engine/gc_profiler.rb', line 22

def initialize
  if self.class.enabled?
    @last_timestamp = call_time
    @last_count = call_count
  end
end

Instance Method Details

#captureObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/new_relic/agent/stats_engine/gc_profiler.rb', line 29

def capture
  return unless self.class.enabled?
  return if !scope_stack.empty? && scope_stack.last.name == "GC/cumulative"

  num_calls = call_count - @last_count
  # microseconds to seconds
  elapsed = (call_time - @last_timestamp).to_f / 1_000_000.0
  @last_timestamp = call_time
  @last_count = call_count
  reset

  record_gc_metric(num_calls, elapsed)
  elapsed
end

#resetObject



44
# File 'lib/new_relic/agent/stats_engine/gc_profiler.rb', line 44

def reset; end