From: Vincent Isambart Date: 2008-01-22T02:56:39+09:00 Subject: Re: an example of performance improvements On Jan 21, 2008, at 6:32 PM, Kornelius Kalnbach wrote: > Martin Duerst wrote: >> Any help (e.g. simple examples where performance is clearly non- >> linear where it should be close to linear) is appreciated. > maybe http://groups.google.de/group/ruby-talk-google/msg/922661ab87c88a01 I think this example can be shorten much more to see the real cause of the problem. With this example, hard to say the real reason of the slowdown (regexps, M17N...?). I made it shorter: ~/tmp% cat e.rb require 'benchmark' include Benchmark logfile = "\n"*5 bm(12) do |test| test.report('Simple:') do 500000.times do logfile.each_line { } end end end ~/tmp% ruby -v e.rb ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0] user system total real Simple: 1.110000 0.000000 1.110000 ( 1.114068) ~/tmp% ruby-1.9 -v e.rb ruby 1.9.0 (2008-01-19 revision 0) [i686-darwin9.1.0] user system total real Simple: 6.240000 2.870000 9.110000 ( 9.122006) That way you can see that the reason the code is much slower is the each_line.