开发者

Rails3 performance is slower than Rails2 - any solution to improve performance

I am working on upgrading an application from Rails 2.3.4 to Rails 3.0.7 and noticed that the performance of Rails 3 is slower(taking twice the time of Rails2) especially because of Active record. Is there any way to improve the performance.

Ruby version : 1.8.7

I did some basic benchmarks in my Rails console and here is the output.

Rails 3.0.7

Benchmark.measure { 25.upto(300){|i| u = User.find_by_id(i); p u.username if u}}
#<Benchmar开发者_如何学Ck::Tms:0xb5cbfd80 @cutime=0.0, @label="", @stime=0.0199999999999996, @real=0.61863899230957, @utime=0.220000000000002, @total=0.240000000000002, @cstime=0.0>

Rails 2.3.4

Benchmark.measure { 25.upto(300){|i| u = User.find_by_id(i); p u.username if u}}

#<Benchmark::Tms:0xb5edd324 @cutime=0.0, @label="", @stime=0.0300000000000002, @total=0.150000000000001, @real=0.467315912246704, @utime=0.120000000000001, @cstime=0.0>

In Rails 2 it takes around 0.46 seconds to find 275 records and print their username whereas in Rails 3 took 0.61 seconds.


anyway, what is purpose of the question? do you want to choose the particular Rails version to use?

if you only care why Rails became slower than before, you can use Github Issues to put the bugreport to Rails core Team

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜