Ruby1.9 and ActiveRecord


#1

I wanted to switch my app from ruby 1.8 to 1.9 but I notice
ar-extensions’ ActiveRecord#import takes longer. The code to demonstrate
it is attached. There is no significant time difference in both
variations in ruby 1.8 (I used fastercsv for 1.8). It looks like 1.9
issue, but first of all I’d appreciate if somebody can confirm this
behavior

Thanks in advance.
-andre

------ test_ar.rb -----
require ‘ar-extensions’
require ‘csv’

ActiveRecord::Base.establish_connection :adapter => ‘sqlite3’, :dbfile
=> ‘:memory:’
ActiveRecord::Schema.define do
create_table ‘jobs’ do |t|
t.column :xid, :integer
t.column :user, :string
t.column :time, :time
t.column :duration, :integer
t.column :machine, :string
t.column :command, :string
end
end

This one is slow. Notice local variable “job”

job = Class.new ActiveRecord::Base do
set_table_name ‘jobs’
end

This one is fast. Notice constant “Job”

#Job = Class.new ActiveRecord::Base do

set_table_name ‘jobs’

#end
#job = Job

data = CSV.read “data.csv”, :headers => false
job.import %w{ xid user time duration machine command }, data,
:validate => false

Fast one (with constant Job)

[lwe1:fx] time ruby19 test_ar.rb
– create_table(“jobs”)
-> 0.0701s
6.349u 0.231s 0:06.97 94.2% 0+0k 0+0io 0pf+0w

Slow one (with local variable job)

[lwe1:fx] time ruby19 test_ar.rb
– create_table(“jobs”)
-> 0.0647s
27.533u 0.270s 0:28.08 99.0% 0+0k 0+0io 0pf+0w