mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
cache the instrumentor for a speed gain
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user