Rails Scripts Slow?

H

HBTaylor

I have just started looking at Ruby and Ruby on Rails, and have run
into a question. It may very well be something in an FAQ or something,
but I haven't had luck framing the right query to find it. Thanks for
any help out there.

I have been following Curt Hibbs' tutorial from ONLamp, and the Rails
scripts seem to be VERY slow to execute. For example, just running
"ruby script/generate" to get the usage information takes more than 30
seconds. If I run "ruby -v script\generate", I see a whole slew of
messages go by, and there are pauses after various messages (i.e.,
"method redefined" and "ambiguous first argument"). I can include the
verbose messages if needed, but don't want to take up space if it is
something I should have found otherwise.

Some details:

OS : Windows XP SP2
Processor: 2.8GHz Celeron
Ruby version : 1.8.2
Rails: Installed via gem (on April 8, 2005)

Running "ruby -v" returns a value almost instaneously.
Running a trivial "Hello World" application executes almost
instaneously.

I don't know if there is something weird with my configuration, or if
there is some way to cache the information so it isn't reloaded each
time, but it seems like those scripts should execute more quickly. Am I
off base, or is that amount of time usual for those generate, etc.,
scripts?

Performance of the Rails application itself seems to be okay (I'm
running through WEBrick at the moment) but not blindingly fast.

Thanks again for any help.

H.B.
 
C

Curt Hibbs

HBTaylor said:
I have just started looking at Ruby and Ruby on Rails, and have run
into a question. It may very well be something in an FAQ or something,
but I haven't had luck framing the right query to find it. Thanks for
any help out there.

I have been following Curt Hibbs' tutorial from ONLamp, and the Rails
scripts seem to be VERY slow to execute. For example, just running
"ruby script/generate" to get the usage information takes more than 30
seconds. If I run "ruby -v script\generate", I see a whole slew of
messages go by, and there are pauses after various messages (i.e.,
"method redefined" and "ambiguous first argument"). I can include the
verbose messages if needed, but don't want to take up space if it is
something I should have found otherwise.

Some details:

OS : Windows XP SP2
Processor: 2.8GHz Celeron
Ruby version : 1.8.2
Rails: Installed via gem (on April 8, 2005)

Running "ruby -v" returns a value almost instaneously.
Running a trivial "Hello World" application executes almost
instaneously.

I don't know if there is something weird with my configuration, or if
there is some way to cache the information so it isn't reloaded each
time, but it seems like those scripts should execute more quickly. Am I
off base, or is that amount of time usual for those generate, etc.,
scripts?

Performance of the Rails application itself seems to be okay (I'm
running through WEBrick at the moment) but not blindingly fast.

Thanks again for any help.

I'm sorry I can't be much help, but its definitely something wrong with
your system. Running a "ruby script\generate" for me takes only a few
seconds on my WinXP SP2 that is a 1.5GHz AMD Athlon.

Curt
 
H

HBTaylor

Curt,

Thanks at least for confirming that it SHOULDN'T be the case. I still
can't figure out why it is doing that. I'll try on another couple of
machines and see if I can infer any causes from differences among the
machines.

H.B.
 
D

Douglas Livingstone

For example, just running
"ruby script/generate" to get the usage information takes more than 30
seconds.

And I was thinking that my computer's 2 second start time for any
loacl ruby script was slow!
 
S

Steve V

Thanks at least for confirming that it SHOULDN'T be the case. I still
can't figure out why it is doing that. I'll try on another couple of
machines and see if I can infer any causes from differences among the
machines.

Any luck determining the cause of this? I experience the same problem when
generating Rails code. I'm on W2K, with an Athlon 2200XP. It takes about 17
seconds on average which seems absolutely absurd considering what exactly it
is generating.

Steve
 
S

Steve V

Can you profile it? (might be able to pass -r profile ?)

Apologies to the group if multiple versions of this message came through.
I'm assuming I exceeded some maximum byte threshold when attaching the whole
profiling.

The profile is attached. The offender appears to be #toplevel(which only
appears once in the whole profile). To possibly save some time I have pasted
below the #toplevel line, as well as surrounding lines.

0.00 22.12 0.00 4 0.00 0.00
SOAP::SOAPExternalReference#method_added
0.00 22.12 0.00 1 0.00 0.00
ActiveRecord::Base#configurations
0.00 22.12 0.00 3 0.00 0.00
XSD::XSDByte#method_added
0.00 22.12 0.00 3 0.00 0.00
ERB::Compiler#initialize
0.00 22.12 0.00 1 0.00 0.00
#<Class:0x3c97558>#initialize
0.00 22.12 0.00 14 0.00 0.00 File#exists?
0.00 22.12 0.00 1 0.00 0.00 Float#**
0.00 22.12 0.00 48 0.00 7.48 OptionParser#search
0.00 22.12 0.00 2 0.00 8.00
Class#class_inheritable_accessor
0.00 22.12 0.00 1 0.00 22094.00 #toplevel
0.00 22.12 0.00 2 0.00 0.00
Gem.ensure_gem_subdirectories
0.00 22.12 0.00 7 0.00 0.00 IO#close
0.00 22.12 0.00 2 0.00 0.00
Rails::Generator::Spec#class_name
0.00 22.12 0.00 1 0.00 0.00 Kernel.untaint
0.00 22.12 0.00 1 0.00 0.00 String#rstrip
0.00 22.12 0.00 1 0.00 672.00
Rails::Generator::Manifest#replay
0.00 22.12 0.00 1 0.00 0.00
SOAP::Mapping::TypedArrayFactory_#initialize
0.00 22.12 0.00 1 0.00 0.00 Kernel.method_added
0.00 22.12 0.00 3 0.00 0.00
SOAP::Mapping::DateTimeFactory_#method_added
0.00 22.12 0.00 9 0.00 0.00
SOAP::Mapping::Factory#method_added
0.00 22.12 0.00 4 0.00 0.00 OptionParser#separator

So I guess the question is... What the heck does #toplevel do? In my case,
what is it doing that it's not supposed to?

Thanks,
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top