From 5cfe4e6ca51dc13ba596168ead8552f77d81c9e0 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 25 Mar 2010 11:46:23 -0300 Subject: [PATCH 1/5] Allow deprecation messages with or without a final period. --- activesupport/lib/active_support/deprecation.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) From 6db4cb361e0b96ec82e3f7e7fa064fb25ce12439 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 12:24:34 -0300 Subject: [PATCH 2/5] Add examples to performance script that were included in version 3. --- activerecord/examples/performance.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb index 53acd62f47057..0e0df24114367 100755 --- a/activerecord/examples/performance.rb +++ b/activerecord/examples/performance.rb @@ -155,6 +155,23 @@ 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 + summary 'Total' end From 5be55281332f37a7c0f4189f0cbfe01b1c95856d Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 30 Sep 2010 09:40:46 -0300 Subject: [PATCH 3/5] Add examples to performance script that were included in version 3. --- activerecord/examples/performance.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb index 0e0df24114367..0b570eee75c49 100755 --- a/activerecord/examples/performance.rb +++ b/activerecord/examples/performance.rb @@ -172,6 +172,23 @@ def self.feel(exhibits) exhibits.each { |e| e.feel } end 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 From fe3c1e51d65348ab3c61ff3588fa2bf114d9b9b5 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 30 Sep 2010 09:42:25 -0300 Subject: [PATCH 4/5] Use detect instead select to avoid sh [..] command not found. --- activerecord/examples/performance.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb index 0b570eee75c49..399c7e1c2f686 100755 --- a/activerecord/examples/performance.rb +++ b/activerecord/examples/performance.rb @@ -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 From 678d36fb7b1f7e588fdd7b95920a47741098ad13 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 30 Sep 2010 09:43:12 -0300 Subject: [PATCH 5/5] Fix performance script error: `real_connect': can't convert Pathname into String (TypeError). --- activerecord/examples/performance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb index 399c7e1c2f686..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)