Diff
Modified: trunk/activerecord-jdbc/bench/bench_find_all.rb (1126 => 1127)
--- trunk/activerecord-jdbc/bench/bench_find_all.rb 2008-08-22 21:02:46 UTC (rev 1126)
+++ trunk/activerecord-jdbc/bench/bench_find_all.rb 2008-08-27 15:30:57 UTC (rev 1127)
@@ -1,33 +1,5 @@
-=begin
-+----------+------+-----+---------+-----------------+----------------+
-| Field | Type | Null | Key | Default | Extra |
-+-------------+--------------+------+-----+---------+----------------+
-| id | int(11) | NO | PRI | NULL | auto_increment |
-| name | varchar(255) | YES | | NULL | |
-| description | text | YES | | NULL | |
-| created_at | datetime | YES | | NULL | |
-| updated_at | datetime | YES | | NULL | |
-+-------------+--------------+------+-----+---------+----------------+
-=end
+require File.dirname(__FILE__) + '/bench_model'
-ENV["RAILS_ENV"] = "production"
-require 'rubygems'
-require 'active_record'
-require 'benchmark'
-
-is_jruby = defined? RUBY_ENGINE && RUBY_ENGINE == "jruby"
-
-ActiveRecord::Base.establish_connection(
- :adapter => is_jruby ? "jdbcmysql" : "mysql",
- :host => "localhost",
- :username => "root",
- :database => "ar_bench"
-)
-
-class Widget < ActiveRecord::Base; end
-
-ActiveRecord::Base.logger = Logger.new(File.expand_path(File.dirname(__FILE__) + "/database.log"))
-
TIMES = (ARGV[0] || 5).to_i
Benchmark.bm do |make|
TIMES.times do
Added: trunk/activerecord-jdbc/bench/bench_find_all_mt.rb (0 => 1127)
--- trunk/activerecord-jdbc/bench/bench_find_all_mt.rb (rev 0)
+++ trunk/activerecord-jdbc/bench/bench_find_all_mt.rb 2008-08-27 15:30:57 UTC (rev 1127)
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/bench_model'
+
+TIMES = (ARGV[0] || 5).to_i
+Benchmark.bm do |make|
+ TIMES.times do
+ make.report do
+ thrs = []
+ errs = 0
+ 10.times do
+ thrs << Thread.new do
+ 1000.times do
+ begin
+ Widget.find(:all)
+ rescue Exception => e
+ errs += 1
+ Widget.logger.warn e.to_s
+ end
+ end
+ Widget.clear_active_connections!
+ end
+ end
+ thrs.each {|t| t.join}
+ puts "errors: #{errs}" if errs > 0
+ end
+ end
+end
Added: trunk/activerecord-jdbc/bench/bench_model.rb (0 => 1127)
--- trunk/activerecord-jdbc/bench/bench_model.rb (rev 0)
+++ trunk/activerecord-jdbc/bench/bench_model.rb 2008-08-27 15:30:57 UTC (rev 1127)
@@ -0,0 +1,62 @@
+=begin
++----------+------+-----+---------+-----------------+----------------+
+| Field | Type | Null | Key | Default | Extra |
++-------------+--------------+------+-----+---------+----------------+
+| id | int(11) | NO | PRI | NULL | auto_increment |
+| name | varchar(255) | YES | | NULL | |
+| description | text | YES | | NULL | |
+| created_at | datetime | YES | | NULL | |
+| updated_at | datetime | YES | | NULL | |
++-------------+--------------+------+-----+---------+----------------+
+=end
+
+ENV["RAILS_ENV"] = "production"
+begin
+ print "Loading ActiveRecord w/o gems..."
+ require 'active_record'
+ require 'active_record/version'
+ puts "version #{ActiveRecord::VERSION::STRING}"
+rescue LoadError
+ puts "FAILED."
+ print "Loading ActiveRecord with gems..."
+ require 'rubygems'
+ gem 'activerecord'
+ puts "version #{Gem.loaded_specs['activerecord'].version.version}"
+ require 'active_record'
+end
+require 'benchmark'
+
+if defined? RUBY_ENGINE && RUBY_ENGINE == "jruby"
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../drivers/mysql/lib'
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../adapters/mysql/lib'
+ require 'active_record/connection_adapters/jdbcmysql_adapter'
+end
+
+require 'logger'
+ActiveRecord::Base.logger = Logger.new(File.expand_path(File.dirname(__FILE__) + "/debug.log"))
+
+ActiveRecord::Base.establish_connection(
+ :adapter => "mysql",
+ :host => "localhost",
+ :username => "root",
+ :database => "ar_bench",
+ :pool => 10,
+ :wait_timeout => 0.5
+)
+
+class CreateWidgets < ActiveRecord::Migration
+ def self.up
+ create_table :widgets do |t|
+ t.string :name
+ t.text :description
+ t.timestamps
+ end
+ end
+end
+
+CreateWidgets.up unless ActiveRecord::Base.connection.tables.include?("widgets")
+
+class Widget < ActiveRecord::Base; end
+
+ActiveRecord::Base.clear_active_connections!
Modified: trunk/activerecord-jdbc/bench/bench_new.rb (1126 => 1127)
--- trunk/activerecord-jdbc/bench/bench_new.rb 2008-08-22 21:02:46 UTC (rev 1126)
+++ trunk/activerecord-jdbc/bench/bench_new.rb 2008-08-27 15:30:57 UTC (rev 1127)
@@ -1,31 +1,5 @@
-=begin
-+----------+------+-----+---------+-----------------+----------------+
-| Field | Type | Null | Key | Default | Extra |
-+-------------+--------------+------+-----+---------+----------------+
-| id | int(11) | NO | PRI | NULL | auto_increment |
-| name | varchar(255) | YES | | NULL | |
-| description | text | YES | | NULL | |
-| created_at | datetime | YES | | NULL | |
-| updated_at | datetime | YES | | NULL | |
-+-------------+--------------+------+-----+---------+----------------+
-=end
+require File.dirname(__FILE__) + '/bench_model'
-ENV["RAILS_ENV"] = "production"
-require 'rubygems'
-require 'active_record'
-require 'benchmark'
-
-is_jruby = defined? RUBY_ENGINE && RUBY_ENGINE == "jruby"
-
-ActiveRecord::Base.establish_connection(
- :adapter => is_jruby ? "jdbcmysql" : "mysql",
- :host => "localhost",
- :username => "root",
- :database => "ar_bench"
-)
-
-class Widget < ActiveRecord::Base; end
-
TIMES = (ARGV[0] || 5).to_i
Benchmark.bm(30) do |make|
TIMES.times do
Modified: trunk/activerecord-jdbc/bench/bench_new_valid.rb (1126 => 1127)
--- trunk/activerecord-jdbc/bench/bench_new_valid.rb 2008-08-22 21:02:46 UTC (rev 1126)
+++ trunk/activerecord-jdbc/bench/bench_new_valid.rb 2008-08-27 15:30:57 UTC (rev 1127)
@@ -1,31 +1,5 @@
-=begin
-+----------+------+-----+---------+-----------------+----------------+
-| Field | Type | Null | Key | Default | Extra |
-+-------------+--------------+------+-----+---------+----------------+
-| id | int(11) | NO | PRI | NULL | auto_increment |
-| name | varchar(255) | YES | | NULL | |
-| description | text | YES | | NULL | |
-| created_at | datetime | YES | | NULL | |
-| updated_at | datetime | YES | | NULL | |
-+-------------+--------------+------+-----+---------+----------------+
-=end
+require File.dirname(__FILE__) + '/bench_model'
-ENV["RAILS_ENV"] = "production"
-require 'rubygems'
-require 'active_record'
-require 'benchmark'
-
-is_jruby = defined? RUBY_ENGINE && RUBY_ENGINE == "jruby"
-
-ActiveRecord::Base.establish_connection(
- :adapter => is_jruby ? "jdbcmysql" : "mysql",
- :host => "localhost",
- :username => "root",
- :database => "ar_bench"
-)
-
-class Widget < ActiveRecord::Base; end
-
TIMES = (ARGV[0] || 5).to_i
Benchmark.bm(30) do |make|
TIMES.times do
Modified: trunk/activerecord-jdbc/bench/bench_valid.rb (1126 => 1127)
--- trunk/activerecord-jdbc/bench/bench_valid.rb 2008-08-22 21:02:46 UTC (rev 1126)
+++ trunk/activerecord-jdbc/bench/bench_valid.rb 2008-08-27 15:30:57 UTC (rev 1127)
@@ -1,31 +1,5 @@
-=begin
-+----------+------+-----+---------+-----------------+----------------+
-| Field | Type | Null | Key | Default | Extra |
-+-------------+--------------+------+-----+---------+----------------+
-| id | int(11) | NO | PRI | NULL | auto_increment |
-| name | varchar(255) | YES | | NULL | |
-| description | text | YES | | NULL | |
-| created_at | datetime | YES | | NULL | |
-| updated_at | datetime | YES | | NULL | |
-+-------------+--------------+------+-----+---------+----------------+
-=end
+require File.dirname(__FILE__) + '/bench_model'
-ENV["RAILS_ENV"] = "production"
-require 'rubygems'
-require 'active_record'
-require 'benchmark'
-
-is_jruby = defined? RUBY_ENGINE && RUBY_ENGINE == "jruby"
-
-ActiveRecord::Base.establish_connection(
- :adapter => is_jruby ? "jdbcmysql" : "mysql",
- :host => "localhost",
- :username => "root",
- :database => "ar_bench"
-)
-
-class Widget < ActiveRecord::Base; end
-
TIMES = (ARGV[0] || 5).to_i
Benchmark.bm(30) do |make|
TIMES.times do