From fc088d4e8fdc7fcc710df094ce4ae6faa27d8c8d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 25 Jul 2010 11:11:51 -0700 Subject: cache the instrumentor for a speed gain --- .../lib/active_record/connection_adapters/abstract_adapter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 4799b693c5..618560087e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -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 -- cgit v1.2.3