Time.now slow on the first call?

I noticed that running this trivial script

Time.now

on windows takes something like 0.05s the first time (fast after that),
and on linux it appears to take 0.1s (just for that line).
Is this expected?
Thanks.
-r

For me:

Windows:

jruby -b -e “1”
Runtime: 15 ms

jruby -b -e “Time.now”
Runtime: 46 ms

Linux (in Virtualbox)

jruby -b -e “1”
Runtime: 29 ms

jruby -b -e “Time.now”
Runtime: 88 ms

So there is not much difference. And for JVM, the startup is not its
greatest strengths, not warmed-up JVM also is not terribly fast (at
first). So it is expected that some first early executions are much
slower at the beginnig.

Thanks,
–Vladimir

On Thu, Feb 4, 2010 at 7:49 PM, Roger P. [email protected] wrote:

Posted via http://www.ruby-forum.com/.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

To add to that point: these are generally unimportant. The JVM has its
own
JIT compiler, and on top of that, the JRuby team have something very
similar
to JIT working for JRuby itself! I can’t speak for JRuby JIT (read more
about it here
http://www.realjenius.com/2009/10/06/distilling-jruby-the-jit-compiler/),
but it takes the JVM a bit to warm up, after which, performance will be
amazing compared to any other Ruby VM.

jruby -b -e “1”
Runtime: 29 ms

jruby -b -e “Time.now”
Runtime: 88 ms

That type of startup time is expected, huh? Ok I guess…
-r

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs