Class: Harrods::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/harrods/tracer.rb

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ Tracer

Returns a new instance of Tracer.



4
5
6
# File 'lib/harrods/tracer.rb', line 4

def initialize(db)
  @db = db
end

Instance Method Details

#record(key, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/harrods/tracer.rb', line 8

def record(key, &block)
  start_ram, start_objects = begin_analysis
  gc_runs, gc_time         = nil, nil
  begin
    yield
  ensure
    used_ram, used_objects, gc_runs, gc_time = end_and_log_analysis(key, start_ram, start_objects)
    @db.flush!
  end
  return [used_ram, used_objects, gc_runs, gc_time]
end