cache the instrumentor for a speed gain

This commit is contained in:
Aaron Patterson
2010-07-25 11:11:51 -07:00
parent b7e0408ca9
commit fc088d4e8f

View File

@@ -44,6 +44,7 @@ module ActiveRecord
@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 @@ module ActiveRecord
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