提交 fc088d4e 编写于 作者: A Aaron Patterson

cache the instrumentor for a speed gain

上级 b7e0408c
...@@ -44,6 +44,7 @@ def initialize(connection, logger = nil) #:nodoc: ...@@ -44,6 +44,7 @@ def initialize(connection, logger = nil) #:nodoc:
@runtime = 0 @runtime = 0
@query_cache_enabled = false @query_cache_enabled = false
@query_cache = {} @query_cache = {}
@instrumenter = ActiveSupport::Notifications.instrumenter
end end
# Returns the human-readable name of the adapter. Use mixed case - one # Returns the human-readable name of the adapter. Use mixed case - one
...@@ -199,10 +200,9 @@ def current_savepoint_name ...@@ -199,10 +200,9 @@ def current_savepoint_name
def log(sql, name) def log(sql, name)
name ||= "SQL" name ||= "SQL"
instrumenter = ActiveSupport::Notifications.instrumenter
info = {} info = {}
result = instrumenter.instrument("sql.active_record", result = @instrumenter.instrument("sql.active_record",
{:sql => sql, :name => name, :connection_id => object_id}, info) do {:sql => sql, :name => name, :connection_id => object_id}, info) do
yield yield
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册