Issue #6183 has been updated by gregolsen (Innokenty Mikhailov).


That's because each time you mapping lazy enumerator another proc objected added to procs array, so in your example you effectively mapping 3 times.
I should return new enumerator object rather than modifying existing one while calling lazy map or select (or whatever lazy method).

A lot of work should be done to finish this patch: all other lazy methods should be added.
Also I'm getting an error while working with big arrays (> 10^4).
But if you are all positive about the approach I'll happily proceed and do my best to make this fully work.
----------------------------------------
Bug #6183: Enumerator::Lazy performance issue
https://bugs.ruby-lang.org/issues/6183#change-25638

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/