之前测过早期 rc 版本,性能有提升
这个版本的更新内容: http://svn.ruby-lang.org/repos/ruby/tags/v1_9_3_0/NEWS
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/40527
在 Ruby 1.9.2 下面,Rails 大项目明显会感觉到开发环境和启动速度缓慢,原因在于 require 的 issue,所有有人除了这个 patch : https://gist.github.com/996418
Ruby 1.9.3 的性能改进明显的地方就是修载入时间的问题。
http://www.rubyinside.com/ruby-1-9-3-faster-loading-times-require-4927.html
安装
$ cd ~/.rvm/archives $ curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.bz2 $ rvm install 1.9.3-p0 $ rvm 1.9.3-p0 $ ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
简单的测试:
./script/rails runner "puts 37337"
1.9.2-p290 ---- 16.92s user 1.43s system 69% cpu 26.423 total
ree-2011.03 ---- 11.46s user 1.23s system 70% cpu 17.955 total
1.9.3-p0 ---- 7.23s user 0.59s system 98% cpu 7.942 total
patchlevel: 334, release_date: 2011-02-18, ruby_version: 1.8.7, ruby_platform: i686-darwin11.1.0
********************************************************************************
user system total real
Date.today 9.060000 0.010000 9.070000 ( 9.095868)
Date.new 12.890000 0.060000 12.950000 ( 13.964456)
Array append 0.310000 0.000000 0.310000 ( 0.314164)
Regexp match 0.810000 0.000000 0.810000 ( 0.826616)
Random 0.100000 0.000000 0.100000 ( 0.100246)
Array index 0.440000 0.000000 0.440000 ( 0.483725)
Array flat 2.530000 0.030000 2.560000 ( 2.681633)
Class.new 0.190000 0.000000 0.190000 ( 0.197483)
patchlevel: 0, release_date: 2011-10-30, ruby_version: 1.9.3, ruby_platform: x86_64-darwin11.2.0
********************************************************************************
user system total real
Date.today 0.700000 0.000000 0.700000 ( 0.704521)
Date.new 0.480000 0.010000 0.490000 ( 0.482028)
Array append 0.090000 0.000000 0.090000 ( 0.095969)
Regexp match 0.890000 0.000000 0.890000 ( 0.890583)
Random 0.130000 0.000000 0.130000 ( 0.133199)
Array index 0.350000 0.000000 0.350000 ( 0.356596)
Array flat 1.480000 0.000000 1.480000 ( 1.489049)
Class.new 0.120000 0.000000 0.120000 ( 0.133629)
patchlevel: 290, release_date: 2011-07-09, ruby_version: 1.9.2, ruby_platform: x86_64-darwin11.0.0
********************************************************************************
user system total real
Date.today 3.840000 0.020000 3.860000 ( 4.124494)
Date.new 3.220000 0.010000 3.230000 ( 3.393119)
Array append 0.080000 0.000000 0.080000 ( 0.085052)
Regexp match 1.030000 0.010000 1.040000 ( 1.053746)
Random 0.090000 0.000000 0.090000 ( 0.092339)
Array index 0.390000 0.000000 0.390000 ( 0.398123)
Array flat 1.390000 0.040000 1.430000 ( 1.479191)
Class.new 0.130000 0.000000 0.130000 ( 0.125919)
但是实际项目中效果不好,看数据
1.9.3-p0 的: Started GET "/topics" Completed 200 OK in 185ms (Views: 160.3ms | Mongo: 22.2ms)
Started GET "/wiki" Completed 200 OK in 52ms (Views: 48.7ms | Mongo: 2.3ms)
Started GET "/topics/6" Completed 200 OK in 116ms (Views: 90.7ms | Mongo: 19.7ms)
1.9.2 打过补丁的: Started GET "/topics" Completed 200 OK in 79ms (Views: 58.7ms | Mongo: 18.6ms)
Started GET "/wiki" Completed 200 OK in 18ms (Views: 15.7ms | Mongo: 1.8ms)
Started GET "/topics/6" Completed 200 OK in 65ms (Views: 48.4ms | Mongo: 10.0ms)