- 浏览: 60770 次
最近访客 更多访客>>
最新评论
-
healer_kx:
Reading~healer.kx~~~~~~~
编译器的书 -
yawl:
"SVM are some of the most ...
classifier算法优缺点 -
coderplay:
SVM有啥优点? 没整过, 只是知道算法是咋回事. 依算法描述 ...
classifier算法优缺点 -
yawl:
我现在在做sentiment analysis的,看这方面的p ...
classifier算法优缺点 -
luven:
好看不重要,关键看创意!
Rails Rumble -- 48小时内完成的131个 application
Two weeks ago, Antonio Cangiano compared the performance of different ruby implementations using Ruby 1.9 (YARV)'s benchmark suite. His numbers got me thinking: all alternative implementations performed badly -- most are even way slower than ruby 1.8.5. Does it signal that JVM and .NET are bad platform for Ruby language?
With this doubt I tried the benchmark with XRuby. XRuby is a ruby compiler. Unlike other implementations, it generates Java bytecode that run directly on JVM. But at first the numbers are not impressive: the 0.1.2 version is still slower than Ruby 1.8.5 in most of the cases.
Maybe I should mention that the XRuby team had done virtually nothing for performance before, and we would avoid optimization as long as possible if it makes our code complicated. But after doing some measurements, it turns out our bad performance are largely caused by a logic 'error': as we know Ruby Fixnum can not have singleton methods, but in 0.1.2 it still lookup an empty method table. And along with some bad code practices (iterating an empty ArrayList without checking if it is empty first etc), it makes method lookup much slower than it should be.
I fixed the problem by adding about 10 lines of code, and got great result: In most benchmarks, XRuby 0.1.3 is faster than Ruby 1.8.5. For some, faster in a significant way. There are still some tests in which we are slower, but it looks like caused by poorly implemented builtin.
The following table shows the benchmark result for XRuby 0.1.3. The best part is: we did it without a method cache. YARV is still faster than XRuby, but we have lots of room to improve too.
>java -Xmx512m -jar xruby-0.1.3.jar benchmark\run.rb
* The test environment is Intel Pentium M 1G CPU, 1G Memory, Windows XP SP2, Java 1.5.0_09.
With this doubt I tried the benchmark with XRuby. XRuby is a ruby compiler. Unlike other implementations, it generates Java bytecode that run directly on JVM. But at first the numbers are not impressive: the 0.1.2 version is still slower than Ruby 1.8.5 in most of the cases.
Maybe I should mention that the XRuby team had done virtually nothing for performance before, and we would avoid optimization as long as possible if it makes our code complicated. But after doing some measurements, it turns out our bad performance are largely caused by a logic 'error': as we know Ruby Fixnum can not have singleton methods, but in 0.1.2 it still lookup an empty method table. And along with some bad code practices (iterating an empty ArrayList without checking if it is empty first etc), it makes method lookup much slower than it should be.
I fixed the problem by adding about 10 lines of code, and got great result: In most benchmarks, XRuby 0.1.3 is faster than Ruby 1.8.5. For some, faster in a significant way. There are still some tests in which we are slower, but it looks like caused by poorly implemented builtin.
The following table shows the benchmark result for XRuby 0.1.3. The best part is: we did it without a method cache. YARV is still faster than XRuby, but we have lots of room to improve too.
>java -Xmx512m -jar xruby-0.1.3.jar benchmark\run.rb
Test | Ruby 1.8.5 | XRuby 0.1.3 |
bm_app_answer.rb | fail | fail |
bm_app_factorial.rb | fail | fail |
bm_app_fib.rb | 20.02 | 12.29 |
bm_app_mandelbrot.rb | 7.099 | 8.252 |
bm_app_pentomino.rb | 289.8 | 538.5 |
bm_app_raise.rb | 4.846 | 3.986 |
bm_app_strconcat.rb | 5.898 | 3.234 |
bm_app_tak.rb | 26.14 | 22.12 |
bm_app_tarai.rb | 20.89 | 18.35 |
bm_loop_times.rb | 14.28 | 19.30 |
bm_loop_whileloop.rb | 26.03 | 19.27 |
bm_loop_whileloop2.rb | 5.257 | 4.786 |
bm_so_ackermann.rb | fail | fail |
bm_so_array.rb | 19.17 | 46.84 |
bm_so_concatenate.rb | 5.727 | 9.684 |
bm_so_count_words.rb | 2.944 | 45.50 |
bm_so_exception.rb | 9.793 | 7.399 |
bm_so_lists.rb | 3.666 | 24.59 |
bm_so_matrix.rb | 6.249 | 8.452 |
bm_so_nested_loop.rb | 15.17 | 13.45 |
bm_so_object.rb | 21.49 | 7.991 |
bm_so_random.rb | 6.169 | 5.888 |
bm_so_sieve.rb | 2.042 | 2.753 |
bm_vm1_block.rb | 64.57 | 38.69 |
bm_vm1_const.rb | 47.47 | 25.57 |
bm_vm1_ensure.rb | 45.54 | 20.01 |
bm_vm1_length.rb | 55.50 | 40.89 |
bm_vm1_rescue.rb | 39.61 | 20.64 |
bm_vm1_simplereturn.rb | 56.02 | 29.06 |
bm_vm1_swap.rb | 76.35 | 30.52 |
bm_vm2_array.rb | 19.34 | 8.532 |
bm_vm2_method.rb | 33.72 | 19.63 |
bm_vm2_poly_method.rb | 45.23 | 20.62 |
bm_vm2_poly_method_ov.rb | 12.64 | 8.261 |
bm_vm2_proc.rb | 21.08 | 17.86 |
bm_vm2_regexp.rb | 13.09 | 30.87 |
bm_vm2_send.rb | 11.71 | 15.75 |
bm_vm2_super.rb | 13.92 | 7.510 |
bm_vm2_unif1.rb | 11.30 | 8.292 |
bm_vm2_zsuper.rb | 15.71 | 7.740 |
bm_vm3_thread_create_join.rb | 0.110 | 1.331 |
* The test environment is Intel Pentium M 1G CPU, 1G Memory, Windows XP SP2, Java 1.5.0_09.
发表评论
-
编译器的书
2008-01-04 01:12 2821有关编译器的书中"Dragon Book" ... -
新的各种ruby实现的性能比较
2007-12-04 06:13 2282Antonio Cangiano今天在blog上更新了各种ru ... -
xruby 0.3.2发布了
2007-11-29 06:00 1563基本和上一个版本(0.3.1)相比变化不大, 大多数都是bug ... -
三周的假期结束了
2007-11-27 20:44 1094用年假回国了一趟。由于时间太短,只在北京和兰州各待了几天。家里 ... -
YAML也要没人维护了
2007-11-05 12:45 1414sishen在xruby mailist提到YAML项目很可能 ... -
Strongtalk项目将无人维护了
2007-11-01 02:05 1976Strongtalk项目的Dave Griswold几天前发了 ... -
和日期相关的库
2007-10-29 22:52 1088上周加入了三个和日期相关的库: time.rb parseda ... -
xruby.googlecode.com
2007-10-23 13:24 1311刚才发现google code最近做了不少改进,其中的就是一个 ... -
复杂的依赖关系
2007-10-19 13:48 1274支持ruby on rails是xruby最重要的目标.我最近 ... -
rails application和web server
2007-10-17 01:31 1419部署到apache/lighthttpd的rails appl ... -
singleton.rb
2007-10-16 00:01 1150上一周的时间,基本上都在争取让xruby能支持singleto ... -
用Jakarta-ORO重写了Regexp
2007-10-10 00:36 2299这个javaeye上的blog本来是利用rss导入做的在国内的 ... -
xruby 0.3.0 released
2007-08-08 05:02 1690I am pleased to announce that X ... -
ruby -y
2007-06-12 15:14 1245For people who are interested i ... -
XRuby 0.2.0 released
2007-05-15 15:15 1171I am glad to announce that XRub ... -
InfoQ article on XRuby
2007-04-17 11:16 907Werner Schuster from InfoQ has ... -
XRuby 0.1.0 released
2007-01-29 22:32 1264[Link of this article: http://x ... -
On-Ruby interview
2007-02-19 03:33 1164Pat Eyler recently interviewed ... -
XRuby 0.1.2 released
2007-03-02 05:58 1242XRuby 0.1.2 is now available fo ... -
Ruby builtin in pure Ruby
2007-03-12 12:50 1529[Update 03/12/2007 If you know ...
相关推荐
标题“5xruby”可能指的是一个与Ruby编程语言相关的项目或者教程,可能是为了介绍或教授如何使用Ruby进行五倍速(高效)的编程。描述中同样提到“5xruby”,但没有提供具体的信息,可能是因为它是项目的简短命名,...
做电影Curso Ruby on Rails 5.x-执行本操作安比恩特RVMListar todas无React,无争议$ rvm list known列表$ rvm get headLista作为本地安装人员$ rvm listInstala umaversãoescolhida $ rvm install x.x.x.xRuby,...
开发指南 软件依赖项 (OS X) $ brew install postgres redis imagemagick pkg-config 设置 $ bundle install $ cp config/application.yml.example config/application.yml $ cp config/database.yml.example ...
本地安装要求Linux,Unix,Windows或Mac OS XRuby在Unix上安装ruby: yum install ruby (或sudo apt-get install ruby1.9.1 )在Mac OS X上安装ruby: curl -L https://get.rvm.io | bash -s stable --ruby 请访问...
dotjs 是一个谷歌扩展,它可根据文件名 ~/.js 来执行 JavaScript ... 而这将会使你很方便地使用 JavaScript 去改进你所喜爱的页面要求OS XRuby 1.8rake (gem install rake)Google Chrome/usr/local/bin in your $PATH
要求Ruby 2.6.3 导轨5.2.3 PostgreSQL 9.4.4安装 $ git clone git@github.com:5xruby/daikichi.git$ cd daikichi# generate key with rake secret$ cp config/secrets.yml.sample config/secrets.yml$ cp config/...