[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby1.9 and ActiveRecord

Andreas S

4/22/2009 10:42:00 PM


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. T=
here is no significant time difference in both variations in ruby 1.8 (I us=
ed fastercsv for 1.8). It looks like 1.9 issue=2C but first of all I'd appr=
eciate if somebody can confirm this behavior

Thanks in advance.
-andre


------ test_ar.rb -----
require 'ar-extensions'
require 'csv'

ActiveRecord::Base.establish_connection :adapter =3D> 'sqlite3'=2C :dbfile =
=3D> ':memory:'
ActiveRecord::Schema.define do
create_table 'jobs' do |t|
t.column :xid=2C :integer
t.column :user=2C :string
t.column :time=2C :time
t.column :duration=2C :integer
t.column :machine=2C :string
t.column :command=2C :string
end
end

# This one is slow. Notice local variable "job"
job =3D Class.new ActiveRecord::Base do
set_table_name 'jobs'
end

# This one is fast. Notice constant "Job"
#Job =3D Class.new ActiveRecord::Base do
# set_table_name 'jobs'

#end
#job =3D Job

data =3D CSV.read "data.csv"=2C :headers =3D> false
job.import %w{ xid user time duration machine command }=2C data=2C :valida=
te =3D> 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


_________________________________________________________________
Rediscover Hotmail=AE: Now available on your iPhone or BlackBerry
http://windowslive.com/RediscoverHotmail?ocid=3DTXT_TAGLM_WL_HM_Re...
Mobile2_042009=

1 Answer

yoker

11/13/2011 3:29:00 PM

0

On Nov 12, 8:10 pm, Thomas Beck <trbe...@frontier.com> wrote:
> On Nov 12, 2:54 pm, yoker <yoke...@yahoo.com> wrote:
>
> > > Ramos' mother was shown on television exclaiming, "Thanks to God!" *
> > * Shouldn't that be, "Gracias Dios!"
>
> "¡Gracias a Dios!" is probably more correct if you're keeping score.


Venezuelan Spanish is not my native language. American English is my
native language.