From: Lars Christensen Date: 2002-05-06T20:04:31+09:00 Subject: Re: Ruby vs. Java vs. Native trivia On Mon, 6 May 2002, Chris Ross wrote: > > On Mon, 06 May 2002 08:15:59 Lars Christensen wrote: > : On Sat, 4 May 2002, Sean Russell wrote: > : : > Hi, > : > > [snip] > : : The Ruby Benchmark isn't all fair, because i'm using a dynamically linked > : version of Ruby, which, by my benchmarks, are 30-40% slower than a > : statically linked (Can anyone explain this?). It doesn't change the > : conclusion though: Ruby is (more than relatively) slow for things like > : this. > : : This on Intel Solaris 2.8. > > The reason that this occurs is due to the following: > > o dynamic: when the application is loaded into memory there is a delay > on startup as the OS's dynamic linker loads all libraries that are > required by it. > > o static: only the executable is loaded into memory - the dynamic > linker doesn't have to do anything. muchos faster. > > Dynamic is more flexible as upgrading the library doesn't require a > recompile of apps that use it. This cannot explain it entirely. On this box, the static version takes 15.31 msecs to startup and evaluate the empty string, and the dynamic takes 19.07 msecs (Averages over 1000 runs). However, consider this: SHARED: $ time ./ruby -e '(10**7).times { a=1 }' user 1m5.680s STATIC: $ time ./ruby -e '(10**7).times { a=1 }' user 0m44.000s There is clearly some runtime bottleneck in the shared version which isn't in the static binary. The shared version of ruby takes close to 50% longer to complete. -- Lars Christensen, larsch@cs.auc.dk