Class: TimeBandits::TimeConsumers::Database

Inherits:
BaseConsumer show all
Defined in:
lib/time_bandits/time_consumers/database.rb

Overview

provide a time consumer interface to ActiveRecord

Instance Method Summary collapse

Methods inherited from BaseConsumer

fields, format, #initialize, instance, key, method_missing, #metrics, prefix, #runtime

Constructor Details

This class inherits a constructor from TimeBandits::TimeConsumers::BaseConsumer

Instance Method Details

#consumedObject



21
22
23
24
25
26
27
# File 'lib/time_bandits/time_consumers/database.rb', line 21

def consumed
  time, calls, hits = reset_stats
  i = Database.instance
  i.sql_query_cache_hits += hits
  i.calls += calls
  i.time += time
end

#current_runtimeObject



29
30
31
# File 'lib/time_bandits/time_consumers/database.rb', line 29

def current_runtime
  Database.instance.time + ActiveRecord::LogSubscriber.runtime
end

#resetObject



16
17
18
19
# File 'lib/time_bandits/time_consumers/database.rb', line 16

def reset
  reset_stats
  super
end