Permalink
Browse files

cache the instrumentor for a speed gain

  • Loading branch information...
1 parent b7e0408 commit fc088d4e8fdc7fcc710df094ce4ae6faa27d8c8d @tenderlove tenderlove committed Jul 25, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -44,6 +44,7 @@ def initialize(connection, logger = nil) #:nodoc:
@runtime = 0
@query_cache_enabled = false
@query_cache = {}
+ @instrumenter = ActiveSupport::Notifications.instrumenter
end
# Returns the human-readable name of the adapter. Use mixed case - one
@@ -199,10 +200,9 @@ def current_savepoint_name
def log(sql, name)
name ||= "SQL"
- instrumenter = ActiveSupport::Notifications.instrumenter
info = {}
- result = instrumenter.instrument("sql.active_record",
+ result = @instrumenter.instrument("sql.active_record",
{:sql => sql, :name => name, :connection_id => object_id}, info) do
yield
end

0 comments on commit fc088d4

Please sign in to comment.