Title: [1115] trunk/activerecord-jdbc/bench/bench_new.rb: Add a "new only" benchmark from JRUBY-2184.
Revision
1115
Author
headius
Date
2008-08-14 04:07:42 -0400 (Thu, 14 Aug 2008)

Log Message

Add a "new only" benchmark from JRUBY-2184.

Added Paths


Diff

Added: trunk/activerecord-jdbc/bench/bench_new.rb (0 => 1115)


--- trunk/activerecord-jdbc/bench/bench_new.rb	                        (rev 0)
+++ trunk/activerecord-jdbc/bench/bench_new.rb	2008-08-14 08:07:42 UTC (rev 1115)
@@ -0,0 +1,38 @@
+=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
+
+TIMES = (ARGV[0] || 5).to_i
+Benchmark.bm(30) do |make|
+  TIMES.times do
+    make.report("Widget.new") do
+      100_000.times do
+        Widget.new
+      end
+    end
+  end
+end
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to