Title: [1126] trunk/activerecord-jdbc/bench/bench_find_all.rb: Add find all benchmark.
Revision
1126
Author
headius
Date
2008-08-22 17:02:46 -0400 (Fri, 22 Aug 2008)

Log Message

Add find all benchmark.

Added Paths


Diff

Added: trunk/activerecord-jdbc/bench/bench_find_all.rb (0 => 1126)


--- trunk/activerecord-jdbc/bench/bench_find_all.rb	                        (rev 0)
+++ trunk/activerecord-jdbc/bench/bench_find_all.rb	2008-08-22 21:02:46 UTC (rev 1126)
@@ -0,0 +1,40 @@
+=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"
+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
+    make.report do
+      10_000.times do
+        Widget.find(:all)
+      end
+    end
+  end
+end
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to