Title: [1114] trunk/activerecord-jdbc: Add the first benchmark from JRUBY-2184.
- Revision
- 1114
- Author
- headius
- Date
- 2008-08-14 04:04:28 -0400 (Thu, 14 Aug 2008)
Log Message
Add the first benchmark from JRUBY-2184.
Added Paths
Diff
Added: trunk/activerecord-jdbc/bench/bench_new_valid.rb (0 => 1114)
--- trunk/activerecord-jdbc/bench/bench_new_valid.rb (rev 0)
+++ trunk/activerecord-jdbc/bench/bench_new_valid.rb 2008-08-14 08:04:28 UTC (rev 1114)
@@ -0,0 +1,44 @@
+=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
+ make.report("widget.valid?") do
+ w = Widget.new
+ 100_000.times do
+ w.valid?
+ end
+ end
+ end
+end
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel