From: "mame (Yusuke Endoh)" Date: 2012-04-03T18:29:17+09:00 Subject: [ruby-core:44106] [ruby-trunk - Bug #6183] Enumerator::Lazy performance issue Issue #6183 has been updated by mame (Yusuke Endoh). Hello, matz (Yukihiro Matsumoto) wrote: > Nobu, could you review the patch? And if you don't see any problem, check it in? I didn't read the patch, but I found a weird behavior. I think the approach is interesting, though. $ cat t.rb a = (1..10).lazy p a.map {|x| x + 1 }.to_a p a.map {|x| x + 1 }.to_a p a.map {|x| x + 1 }.to_a # without the patch $ ./miniruby.org t.rb [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # with the patch applied $ ./miniruby.new t.rb [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] [3, 4, 5, 6, 7, 8, 9, 10, 11, 12] [4, 5, 6, 7, 8, 9, 10, 11, 12, 13] -- Yusuke Endoh ---------------------------------------- Bug #6183: Enumerator::Lazy performance issue https://bugs.ruby-lang.org/issues/6183#change-25633 Author: gregolsen (Innokenty Mikhailov) Status: Assigned Priority: Low Assignee: nobu (Nobuyoshi Nakada) Category: Target version: ruby -v: ruby 2.0.0dev (2012-03-17 trunk 35075) [x86_64-linux] I benchmarked Enumerator::Lazy and that's what I got: user system total real Lazy: 0.690000 0.010000 0.700000 ( 0.733160) Normal: 0.160000 0.010000 0.170000 ( 0.186695) It seems like even with 4 chain links and 3000 elements in initial array, Lazy enumerator is almost 4(!) times slower than the normal case. Instead of performance benefit we've got 4 times performance drawback. See test file attached. -- http://bugs.ruby-lang.org/