How to create 10000 pseudo data for Testing in RoR

I want to test performance of project.
So i want make 10000 record of table for testing.
I don’t know how to ganerate record.
Who can help me? Thanks.

Depends on what you’re trying to test.

If it’s a single table and the values in the database don’t matter, you
can
just add a [0…10000].each loop in seed.rb

Or copy production data

Or use a sql script to load your database

Or one of these
http://watirmelon.com/2012/06/15/three-ways-to-generate-test-data-for-your-ruby-automated-tests/

On Fri, Apr 5, 2013 at 11:08 AM, haxuan lac [email protected]
wrote:

I want to test performance of project.
So i want make 10000 record of table for testing.
I don’t know how to ganerate record.
Who can help me? Thanks.

Greg A.
http://twitter.com/akinsgre

Thanks Greg A.
I’m using MongoDB and in Mongodb has some table as:
user,comment,photo,relationship
And tables have ralationship(user relationship with photos…) …
Could you give me some advice for this problem?Thanks

You can add data via Rails models, like

User.create({ <your attributes for user goes there })

Just use rails code inside seed.rb to generate whatever you like and
then
run rake task which is something like rake db:seed

2013/4/5 haxuan lac [email protected]

You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected]
To post to this group, send email to [email protected]
For more options, visit https://groups.google.com/groups/opt_out.


Pagarbiai,
Gintautas

As far as cloning development DB into test DB, check out
http://stackoverflow.com/questions/2645022/rails-populate-test-database-with-development-data

2013/4/5 Gintautas Šimkus [email protected]

Thanks Greg A.
“Ruby on Rails: Talk” group.
Pagarbiai,
Gintautas


Pagarbiai,
Gintautas

Yes ,Thanks Gintautas
If I want create 1000000(1 million) pseudo data,i can this way for it?
And i hear a gem with called “faker” http://faker.rubyforge.org/
can i using this gem for solve my problem ( create 1000000 pseudo data)?
Thanks very much

Though just simple db:seed and then exporting development DB and
importing
it into test DB should do the trick.

2013/4/5 Gintautas Šimkus [email protected]

Thanks very much
For more options, visit https://groups.google.com/groups/opt_out.


Pagarbiai,
Gintautas


Pagarbiai,
Gintautas

Maybe, I don’t know :slight_smile: you just got to investigate stuff, that’s part of
learning something new process :slight_smile:

2013/4/5 haxuan lac [email protected]

You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected]
To post to this group, send email to [email protected]
For more options, visit https://groups.google.com/groups/opt_out.


Pagarbiai,
Gintautas

huxuan

Faker might be overkill… or might not. Try both approaches and let us
know which works best.

If you have ActiveRecord model defined (say User.rb)

Then just include this in the db/seed.rb

[0…1000000].each do |i|
User.create(:name => “name#{i}”, etc…)
end

A problem with this approach is distribution of data. If you need the
names to be distributed across an alphanumeric range (to mimic real
world
data) then you might want to modify the mechanism for creating the User.

Greg A.
http://twitter.com/akinsgre

Thank Gintautas,Greg A. very much
I will do with instruction of you.
Thank you vey much again!!!

On 06/04/2013, at 2:13 AM, Greg A. [email protected] wrote:

On Fri, Apr 5, 2013 at 11:08 AM, haxuan lac [email protected] wrote:

Props, Greg! I’m impressed with your response. I saw the question, and
these kinds of questions really bother me because they lack specificity.
I was thinking maybe we should have a noob web form app that could help
them build their questions properly for submitting, by asking THEM lots
of questions. :slight_smile: Then we could just point them to it, and say hey, do
this! :slight_smile:

But yeah, “more information please, as much as possible” is such a
common thing to say.

Julian

haxuan lac wrote in post #1104574:

I want to test performance of project.
So i want make 10000 record of table for testing.
I don’t know how to ganerate record.
Who can help me? Thanks.

Look at rails cast #179.
this has a tutorial on using seed.rub to create test data.

http://railscasts.com/episodes/179-seed-data?view=comments

On Fri, Apr 5, 2013 at 6:37 PM, Julian L.
[email protected]wrote:

Props, Greg! I’m impressed with your response. I saw the question, and
these kinds of questions really bother me because they lack specificity. I
was thinking maybe we should have a noob web form app that could help them
build their questions properly for submitting, by asking THEM lots of
questions. :slight_smile: Then we could just point them to it, and say hey, do this! :slight_smile:

But yeah, “more information please, as much as possible” is such a common
thing to say.

Maybe we should also have a big ass sign on-top of it for people who
make
worthless comments, all it needs to say is “don’t make worthless
comments.”
And yes, I realize the irony.

I tried create 10000 pseudo by Faker but it’s very slow.
I fake 1000 record about 20 minutes.
And 10000 record take me 2-3 hours.
please give me some advice about this time I had done with fake pseudo
data(1000 and 10000 pseudo).
Thanks…

On 6 April 2013 03:18, haxuan lac [email protected] wrote:

I tried create 10000 pseudo by Faker but it’s very slow.
I fake 1000 record about 20 minutes.
And 10000 record take me 2-3 hours.
please give me some advice about this time I had done with fake pseudo
data(1000 and 10000 pseudo).

I think it has been suggested several times that you use rake db:seed
with seed.rb. Have you investigated that route?

Colin

On Apr 5, 2013 9:18 PM, “haxuan lac” [email protected] wrote:

I tried create 10000 pseudo by Faker but it’s very slow.
I fake 1000 record about 20 minutes.
And 10000 record take me 2-3 hours.
please give me some advice about this time I had done with fake pseudo
data(1000 and 10000 pseudo).
Thanks…

anytime you use the ORM to insert 10_000 records it’s going to be slow
as
it does them one at a time. i suggest gong the direct sql route in this
case.

Write a Ruby script to do it, invoke it via a rake task.

On Fri, Apr 5, 2013 at 9:38 PM, haxuan lac [email protected] wrote:

You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected]
To post to this group, send email to [email protected]
For more options, visit https://groups.google.com/groups/opt_out.


Best,
Manish Chakravarty

Blog | Twitter | LinkedIn

One approach may be to build the data as a large csv. Which you could
do
from ruby if you wished and you can then keep as a file. Then either
import directly to the db with sql or workbench etc. or if you want to
stay
ruby, load the csv and use ar_extension import to dump the data into
the
db.