diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb index 53acd62f47057..eb2342480d698 100755 --- a/activerecord/examples/performance.rb +++ b/activerecord/examples/performance.rb @@ -25,7 +25,7 @@ /tmp/mysql.sock /var/mysql/mysql.sock /var/run/mysqld/mysqld.sock -]).find { |path| path.socket? } +]).find { |path| path.socket? }.to_s ActiveRecord::Base.establish_connection(conn) @@ -58,7 +58,7 @@ def self.feel(exhibits) exhibits.each { |e| e.feel } end sqlfile = "#{__DIR__}/performance.sql" if File.exists?(sqlfile) - mysql_bin = %w[mysql mysql5].select { |bin| `which #{bin}`.length > 0 } + mysql_bin = %w[mysql mysql5].detect { |bin| `which #{bin}`.length > 0 } `#{mysql_bin} -u #{conn[:username]} #{"-p#{conn[:password]}" unless conn[:password].blank?} #{conn[:database]} < #{sqlfile}` else puts 'Generating data...' @@ -88,7 +88,7 @@ def self.feel(exhibits) exhibits.each { |e| e.feel } end ) end - mysqldump_bin = %w[mysqldump mysqldump5].select { |bin| `which #{bin}`.length > 0 } + mysqldump_bin = %w[mysqldump mysqldump5].detect { |bin| `which #{bin}`.length > 0 } `#{mysqldump_bin} -u #{conn[:username]} #{"-p#{conn[:password]}" unless conn[:password].blank?} #{conn[:database]} exhibits users > #{sqlfile}` end @@ -155,6 +155,40 @@ def self.feel(exhibits) exhibits.each { |e| e.feel } end ar { Exhibit.transaction { Exhibit.new } } end + report 'Model.find(id)' do + id = Exhibit.first.id + ar { Exhibit.find(id) } + end + + report 'Model.find_by_sql' do + ar { Exhibit.find_by_sql("SELECT * FROM exhibits WHERE id = #{(rand * 1000 + 1).to_i}").first } + end + + report 'Model.log', (TIMES * 10) do + ar { Exhibit.connection.send(:log, "hello", "world") {} } + end + + report 'AR.execute(query)', (TIMES / 2) do + ar { ActiveRecord::Base.connection.execute("Select * from exhibits where id = #{(rand * 1000 + 1).to_i}") } + end + + report 'Model.find(id)' do + id = Exhibit.first.id + ar { Exhibit.find(id) } + end + + report 'Model.find_by_sql' do + ar { Exhibit.find_by_sql("SELECT * FROM exhibits WHERE id = #{(rand * 1000 + 1).to_i}").first } + end + + report 'Model.log', (TIMES * 10) do + ar { Exhibit.connection.send(:log, "hello", "world") {} } + end + + report 'AR.execute(query)', (TIMES / 2) do + ar { ActiveRecord::Base.connection.execute("Select * from exhibits where id = #{(rand * 1000 + 1).to_i}") } + end + summary 'Total' end diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 151ae5a10a793..36289cfa7efc9 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -52,7 +52,8 @@ def silence private def deprecation_message(callstack, message = nil) message ||= "You are using deprecated behavior which will be removed from the next major or minor release." - "DEPRECATION WARNING: #{message}. #{deprecation_caller_message(callstack)}" + message += '.' unless message =~ /\.$/ + "DEPRECATION WARNING: #{message} #{deprecation_caller_message(callstack)}" end def deprecation_caller_message(callstack)