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



33
34
35
36
37
38
39
# File 'lib/time_bandits/time_consumers/database.rb', line 33

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



41
42
43
# File 'lib/time_bandits/time_consumers/database.rb', line 41

def current_runtime
  Database.instance.time + self.class.metrics_store.runtime
end

#metrics_storeObject



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

def metrics_store
  ActiveRecord::RuntimeRegistry
end

#resetObject



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

def reset
  reset_stats
  super
end