[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby vs JRuby Performance

Victor Reyes

6/9/2008 1:37:00 PM

[Note: parts of this message were removed to make it a legal post.]

I knew that there was a penalty to be paid when running JRuby, but I did not
know how high.
I developed a Sudoku solver, which actually solves simple to medium
difficult puzzles. I am still struggling to make it solve "hard" problems.
I just installed JRuby yesterday and wanted to compare it against Ruby.

I executed the same program:

The results are in:

ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

*Ruby:
ruby sudoku01final.rb
Elapsed Time: 0.437 Secs*

jruby -v
ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
*JRuby:
jruby sudoku01final.rb
Elapsed Time: 1.058 Secs*

BTW, there is no GUI in my program. I hope to learn the GUI part with JRuby.
That's the main reason why I downloaded JRuby, NetBeans, Java JDK/JRE, Etc.
I guess there is trade-off which one must be willing to accept.

Am I in the ball-park?

Regards,

Victor

18 Answers

Jochen Theodorou

6/9/2008 2:12:00 PM

0

Victor Reyes schrieb:
[...]
> ruby -v
> ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
>
> *Ruby:
> ruby sudoku01final.rb
> Elapsed Time: 0.437 Secs*
>
> jruby -v
> ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
> *JRuby:
> jruby sudoku01final.rb
> Elapsed Time: 1.058 Secs*

jruby has certainly higher startup costs than native Ruby, but that does
not mean its overall performance is bad. I suggest you modify the
program so it runs for example 10 times and then run again. I am sure
the JRuby program will be very much below 10s

bye Jochen

ThoML

6/9/2008 2:25:00 PM

0

> jruby -v
> ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
> *JRuby:
> jruby sudoku01final.rb
> Elapsed Time: 1.058 Secs*

Try to run it with jruby -J-server ...

M. Edward (Ed) Borasky

6/9/2008 2:27:00 PM

0

Victor Reyes wrote:
> I knew that there was a penalty to be paid when running JRuby, but I did not
> know how high.
> I developed a Sudoku solver, which actually solves simple to medium
> difficult puzzles. I am still struggling to make it solve "hard" problems.
> I just installed JRuby yesterday and wanted to compare it against Ruby.
>
> I executed the same program:
>
> The results are in:
>
> ruby -v
> ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
>
> *Ruby:
> ruby sudoku01final.rb
> Elapsed Time: 0.437 Secs*
>
> jruby -v
> ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
> *JRuby:
> jruby sudoku01final.rb
> Elapsed Time: 1.058 Secs*
>
> BTW, there is no GUI in my program. I hope to learn the GUI part with JRuby.
> That's the main reason why I downloaded JRuby, NetBeans, Java JDK/JRE, Etc.
> I guess there is trade-off which one must be willing to accept.
>
> Am I in the ball-park?
>
> Regards,
>
> Victor
>
Send the source to Charlie Nutter ... he is always looking for jRuby
performance test cases.

Lloyd Linklater

6/9/2008 2:45:00 PM

0

Victor Reyes wrote:
> I knew that there was a penalty to be paid when running JRuby, but I did
> not
> know how high.
> I developed a Sudoku solver, which actually solves simple to medium
> difficult puzzles. I am still struggling to make it solve "hard"
> problems.
> I just installed JRuby yesterday and wanted to compare it against Ruby.
>
> I executed the same program:
>
> The results are in:
> *Ruby:
> ruby sudoku01final.rb
> Elapsed Time: 0.437 Secs*
>
> jruby -v
> ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
> *JRuby:
> jruby sudoku01final.rb
> Elapsed Time: 1.058 Secs*
>
> Am I in the ball-park?

According to the metrics posted here, JRuby runs about twice as fast,
takes longer to load and uses a lot more memory. Here is a little
something on the metrics:

http://www.ruby-...topic/...
http://www.ruby-...topic/...
--
Posted via http://www.ruby-....

Victor Reyes

6/9/2008 4:27:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

*Ruby vs JRuby Performance <http://www.ruby-forum.com/topic/155783#...*
Posted by Victor Reyes (Guest)
on 09.06.2008 15:41
[image: (Received via mailing list)]

I knew that there was a penalty to be paid when running JRuby, but I did
not
know how high.
I developed a Sudoku solver, which actually solves simple to medium
difficult puzzles. I am still struggling to make it solve "hard"

problems.
I just installed JRuby yesterday and wanted to compare it against Ruby.

I executed the same program:

The results are in:

ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

*Ruby:
ruby sudoku01final.rb
Elapsed Time: 0.437 Secs*

jruby -v
ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
*JRuby:
jruby sudoku01final.rb
Elapsed Time: 1.058 Secs*

BTW, there is no GUI in my program. I hope to learn the GUI part with

JRuby.
That's the main reason why I downloaded JRuby, NetBeans, Java JDK/JRE,
Etc.
I guess there is trade-off which one must be willing to accept.

Am I in the ball-park?

Regards,

Victor

Reply with quote<http://www.ruby-forum.com/topic/155783?reply_to=686221#po...
*Re: Ruby vs JRuby Performance<http://www.ruby-forum.com/topic/155783#...
*
Posted by Jochen Theodorou (Guest)
on 09.06.2008 16:15
[image: (Received via mailing list)]

Victor Reyes schrieb:
[...]
> jruby sudoku01final.rb
> Elapsed Time: 1.058 Secs*

jruby has certainly higher startup costs than native Ruby, but that does

not mean its overall performance is bad. I suggest you modify the
program so it runs for example 10 times and then run again. I am sure
the JRuby program will be very much below 10s

bye Jochen

Reply with quote<http://www.ruby-forum.com/topic/155783?reply_to=686235#po...
*Re: Ruby vs JRuby Performance<http://www.ruby-forum.com/topic/155783#...
*
Posted by M. Edward (Ed) Borasky (Guest)
on 09.06.2008 16:28
[image: (Received via mailing list)]

Victor Reyes wrote:
> ruby -v
> Elapsed Time: 1.058 Secs*
>

Send the source to Charlie Nutter ... he is always looking for jRuby
performance test cases.

Reply with quote<http://www.ruby-forum.com/topic/155783?reply_to=686241#po...
*Re: Ruby vs JRuby Performance<http://www.ruby-forum.com/topic/155783#...
*
Posted by ThoML (Guest)
on 09.06.2008 16:31

> jruby -v
> ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
> *JRuby:
> jruby sudoku01final.rb
> Elapsed Time: 1.058 Secs*

Try to run it with jruby -J-server ...

Reply with quote<http://www.ruby-forum.com/topic/155783?reply_to=686245#po...
*Re: Ruby vs JRuby Performance<http://www.ruby-forum.com/topic/155783#...
*
Posted by Lloyd Linklater (lloyd <http://www.ruby-forum.com/user/sho...)

on 09.06.2008 16:44

Victor Reyes wrote:
> I knew that there was a penalty to be paid when running JRuby, but I did
> not
> know how high.
> I developed a Sudoku solver, which actually solves simple to medium
> difficult puzzles. I am still struggling to make it solve "hard"
> problems.
> I just installed JRuby yesterday and wanted to compare it against Ruby.
>
> I executed the same program:
>
> The results are in:
> *Ruby:
> ruby sudoku01final.rb
> Elapsed Time: 0.437 Secs*
>
> jruby -v
> ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
> *JRuby:
> jruby sudoku01final.rb
> Elapsed Time: 1.058 Secs*
>
> Am I in the ball-park?

According to the metrics posted here, JRuby runs about twice as fast,
takes longer to load and uses a lot more memory. Here is a little
something on the metrics:

http://www.ruby-forum.com/topic/...
http://www.ruby-forum.com/topic/...


======================================================================================

Team,

First, thank you for all your comments.

As suggested by JoChen, I executed the program under JRuby 14 times.

To be fair to Ruby, I also executed it 14 times under Ruby.
You can see the results below.

As suggested by Ed Borasky, I will send the code to Charlie Nutter, if
I can get his email. Otherwise I can post it here. It is not great

code at all, but it is doing the work for now.

I executed the program using *jruby -J-server* as suggested by ThoML
and results are catastrophic! See the number belows! I only ran it 6
times.
I also can't believe that jruby has been clocked at twice the speed of
ruby since after all, jruby has more overhead than ruby. Then again,

I am not expert on the subject (or any subject).

*JRuby executions:
*Elapsed Time: 0.888
Elapsed Time: 0.881
Elapsed Time: 0.977
Elapsed Time: 0.888
Elapsed Time: 0.872

Elapsed Time: 0.884
Elapsed Time: 0.869
Elapsed Time: 0.892
Elapsed Time: 0.876
Elapsed Time: 0.872
Elapsed Time: 0.882
Elapsed Time: 0.882
Elapsed Time: 0.867
Elapsed Time: 0.881
Elapsed Time: 0.906

Elapsed Time: 0.881

*Ruby executions:*
Elapsed Time: 0.422
Elapsed Time: 0.391
Elapsed Time: 0.407
Elapsed Time: 0.406
Elapsed Time: 0.407

Elapsed Time: 0.422
Elapsed Time: 0.406
Elapsed Time: 0.438
Elapsed Time: 0.406
Elapsed Time: 0.406
Elapsed Time: 0.406
Elapsed Time: 0.39
Elapsed Time: 0.406
Elapsed Time: 0.406
Elapsed Time: 0.422

Elapsed Time: 0.39

*jruby -J-server sudoku01final.rb*
Elapsed Time: 2.474
Elapsed Time: 2.467
Elapsed Time: 2.347
Elapsed Time: 2.404
Elapsed Time: 2.326
Elapsed Time: 2.414

Thank you

Victor

ThoML

6/9/2008 4:59:00 PM

0

> I executed the program using *jruby -J-server* as suggested by ThoML
> and results are catastrophic! See the number belows! I only ran it 6
> times.

I didn't realize how small the numbers already are. Have you checked
the result of

time ruby -v
time jruby -v

just to get a feeling for how much time is spent in startup alone?

Jochen Theodorou

6/9/2008 7:57:00 PM

0

Victor Reyes schrieb:
[...]
> As suggested by JoChen, I executed the program under JRuby 14 times.
>
> To be fair to Ruby, I also executed it 14 times under Ruby.
> You can see the results below.
>
> As suggested by Ed Borasky, I will send the code to Charlie Nutter, if
> I can get his email. Otherwise I can post it here. It is not great
>
> code at all, but it is doing the work for now.
>
> I executed the program using *jruby -J-server* as suggested by ThoML
> and results are catastrophic! See the number belows! I only ran it 6
> times.
> I also can't believe that jruby has been clocked at twice the speed of
> ruby since after all, jruby has more overhead than ruby. Then again,
>
> I am not expert on the subject (or any subject).
>
> *JRuby executions:
> *Elapsed Time: 0.888
> Elapsed Time: 0.881
[...]
> Elapsed Time: 0.881
>
> *Ruby executions:*
> Elapsed Time: 0.422
> Elapsed Time: 0.391
[...]
> Elapsed Time: 0.39
>
> *jruby -J-server sudoku01final.rb*
> Elapsed Time: 2.474
[...]
> Elapsed Time: 2.414

well, looking at these numbers I would suggest you subscribe to the
jruby mailing list and ask why jruby is 100% slower than ruby ;) The
server mode really looks awful... They need to know about this!

bye Jochen

Charles Oliver Nutter

6/10/2008 9:24:00 AM

0

Jochen Theodorou wrote:
> well, looking at these numbers I would suggest you subscribe to the
> jruby mailing list and ask why jruby is 100% slower than ruby ;) The
> server mode really looks awful... They need to know about this!

You are here trolling on the Ruby lists Jochen? Don't you have some
Groovy bugs to be fixing? :)

The server VM starts up a lot slower on most systems, which is the
reason for this test to be invalid. And in general, any benchmark under
5-10s is going to be a pretty poor test of JRuby performance, since the
code might not even get compiled or optimized on such a short run.

- Charlie

Charles Oliver Nutter

6/10/2008 9:28:00 AM

0

Victor Reyes wrote:
> ruby -v
> ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
>
> *Ruby:
> ruby sudoku01final.rb
> Elapsed Time: 0.437 Secs*
>
> jruby -v
> ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]
> *JRuby:
> jruby sudoku01final.rb
> Elapsed Time: 1.058 Secs*

Far too short.

~/amsterdam â?? time ruby -e "puts 1"
1

real 0m0.006s
user 0m0.003s
sys 0m0.004s

~/amsterdam â?? time jruby -e "puts 1"
1

real 0m0.594s
user 0m0.460s
sys 0m0.101s

Is JRuby 100 times slower than Ruby? No. It is too short a test. Run
something longer and you'll get more realistic results.

- Charlie

Jochen Theodorou

6/10/2008 12:16:00 PM

0

Charles Oliver Nutter schrieb:
> Jochen Theodorou wrote:
>> well, looking at these numbers I would suggest you subscribe to the
>> jruby mailing list and ask why jruby is 100% slower than ruby ;) The
>> server mode really looks awful... They need to know about this!
>
> You are here trolling on the Ruby lists Jochen? Don't you have some
> Groovy bugs to be fixing? :)

ah, I didn't try to troll, I put so many ;) in.

> The server VM starts up a lot slower on most systems, which is the
> reason for this test to be invalid. And in general, any benchmark under
> 5-10s is going to be a pretty poor test of JRuby performance, since the
> code might not even get compiled or optimized on such a short run.

well, ok, but it was:

> *jruby -J-server sudoku01final.rb*
> Elapsed Time: 2.474
> Elapsed Time: 2.467
> Elapsed Time: 2.347
> Elapsed Time: 2.404
> Elapsed Time: 2.326
> Elapsed Time: 2.414

that's >12s... unless he did start over again and again, but I assumed
that is not the case because of:

*JRuby executions:* Elapsed Time: 0.888 [...]

vs.

*JRuby:
jruby sudoku01final.rb
Elapsed Time: 1.058 Secs*

but maybe I was wrong.

bye Jochen