=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

Add the first benchmark from JRUBY-2184.
Add the first benchmark from JRUBY-2184.


git-svn-id: 0d15740d2b2329e9094a4e8932733054e5d3e04c@1114 8ba958d5-0c1a-0410-94a6-a65dfc1b28a6
