|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
JRuby speed on Windows?Hi!
I wrote a little ruby script to measure Ruby/JRuby performance in different interpreters/platforms: a script to compute the N:th prime. I guessed that it should run almost equally fast on Windows and Linux. But to my surprise there was a big difference. The same computation with JRuby (the 100_000:th prime) took: Linux: 11 seconds Windows: 34 seconds I used two machine with exactly the same hardware: " Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz". One running Ubuntu 7.10, the other Windows XP Professional. And I had almost the same Java version too (I think): -------------- Windows --------------- c:\> java -version java version "1.6.0_04" Java(TM) SE Runtime Environment (build 1.6.0_04-b12) Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing) -------------- Linux --------------- % java -version java version "1.6.0_03" Java(TM) SE Runtime Environment (build 1.6.0_03-b05) Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode) -------------------------------- To compare the Java versions I also rewrote the algorithm in Java, and then they were equally fast on Windows and Ubuntu. But when I run my ruby-script in JRuby Linux is three times faster. Can you explain this to me? I don't understand the reason for this difference. In both cases I use r5863 of JRuby, built locally on each machine. /Johan Holmberg I attach my script in case it matters: ----------------------------------------- #!/usr/local/bin/ruby require "monitor" def is_prime(i) d = 3 while d*d <= i if i % d == 0 return false end d += 2 end return true end def nth_prime(n) i = 1 count = 1 while count != n i += 2 if is_prime(i) count += 1 end end return i end threads = [] threads.extend(MonitorMixin) t1 = Time.now for str in ARGV threads << Thread.new(str) do |str2| if str2 == "sleep" sleep(5) threads.synchronize do puts "[%f] sleep done " % [ (Time.now - t1), ] end else x2 = str2.to_i nth = nth_prime(x2) threads.synchronize do puts "[%f] %d ---> %d" % [ (Time.now - t1), x2, nth, ] end end end end for t in threads t.join end puts "finishing ..." ----------------------------------------- --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: JRuby speed on Windows?On Feb 11, 2008 1:15 PM, Johan Holmberg <johan556@...> wrote:
> Hi! > > I wrote a little ruby script to measure Ruby/JRuby performance in > different interpreters/platforms: a script to compute the N:th prime. > I guessed that it should run almost equally fast on Windows and > Linux. [...] > -------------- Windows --------------- > c:\> java -version > java version "1.6.0_04" > Java(TM) SE Runtime Environment (build 1.6.0_04-b12) > Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing) > -------------- Linux --------------- > % java -version > java version "1.6.0_03" > Java(TM) SE Runtime Environment (build 1.6.0_03-b05) > Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode) > -------------------------------- > Just after sending my previous mail I discovered that adding the -server option to "java" on Windows eliminates the difference. I'm still a rather "naive" Java user :) /Johan Holmberg --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |