The recent Jruby 1.1b should be nearly or faster than matz ruby
implementation. However, when I try to run it for a big source file
~2Mb, I found that Jruby still around 40% slower than matz ruby. (matz
ruby time is not consistent and I think sometimes the GC occur and block
the execution.)
Any suggestion how to optimize Jruby to make it faster?
Here is my result:
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>jruby main.rb
7.776
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>ruby main.rb
4.317
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>jruby main.rb
7.078
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>ruby main.rb
10.128
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>ruby main.rb
1.864
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>ruby main.rb
3.13
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>jruby main.rb
8.713000000000001
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>ruby main.rb
1.845
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
C:\Home\swong24\smv_material\project\ConfigDBParse\lib>jruby -v
ruby 1.8.5 (2007-11-01 rev 4842) [x86-jruby1.1b1]
Here is my code for main.rb:
++++++++++++++++++++++++++++++
require ‘file_parser’
include CfgDBParser
t1 = Time.now;
prepare_file(‘eaglelake.def’)
loadfile
clean_up
puts Time.now - t1
++++++++++++++++++++++++++++++
eaglelake.def is the big src file, around 2MB. Actually it is a special
format database file. I just reformat it to make it become ruby code.