ok, the following code with 6000 records insert will take 13.3 seconds
to finish (just for the db portion). if i change 6000 to 30000 then it
will take 67 seconds.
it is being run using
ruby script/runner foo.rb
------------------------------------------------------------
code:
srand(123)
frequencies = {}
lengths = {}
6000.times do
phrase = (65+rand(26)).chr + "#{rand(100_000_000)}";
frequencies[phrase] = rand(20);
lengths[phrase] = rand(10);
end
#p frequencies
all_phrases = frequencies.keys
p "Starting inserting records"
time_start = Time.now
Phrase.transaction do
all_phrases.each do |phrase|
recordPhrase = Phrase.create(:s => phrase, :frequency =>
frequencies[phrase], :length => lengths[phrase])
end
end
p "took #{Time.now - time_start} seconds to finish"
p Phrase.count
------------------------------------------------------------
the scheme.rb for the table is
create_table "phrases", :force => true do |t|
t.string "s"
t.integer "frequency"
t.integer "length"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "phrases", ["frequency"], :name =>
"index_phrases_on_frequency"
add_index "phrases", ["length"], :name => "index_phrases_on_length"
add_index "phrases", ["s"], :name => "index_phrases_on_s"
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---