Rails Scripts Slow?

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.

HBTaylor wrote:

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

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

···

On Apr 10, 2005 2:19 AM, HBTaylor <hbtaylor@gmail.com> wrote:

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

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.

Douglas Livingstone wrote:

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

~/rforum : time ruby -e 'puts "aaa"'
aaa

real 0m0.011s
user 0m0.010s
sys 0m0.001s

If you need significantly more than 100 msec to start Ruby on a P-III or P-IV, something is wrong with your setup.

···

--
Best regards,

Alexey Verkhovsky

Ruby Forum: http://ruby-forum.org (moderator)
RForum: http://rforum.andreas-s.net (co-author)
Instiki: http://instiki.org (maintainer)

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

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

···

On Apr 11, 2005 10:46 AM, Steve V <ruby@digitalnothing.com> wrote:

> 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

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