Cs. Henk
3/11/2005 5:33:00 PM
On Fri, Mar 11, 2005 at 12:41:33AM +0900, William Morgan wrote:
> ruby -rgenerator -rbenchmark -e 'a=(1..100000).map{|x|x};g=Generator.new(a);[
> lambda { a.each { |x| x } },
> lambda { while g.next?; g.next; end },
> ].each {|pr| puts Benchmark.measure(&pr) }'
> 0.030000 0.000000 0.030000 ( 0.027388)
> 10.380000 1.190000 11.570000 ( 11.612888)
It's a bit faster if you do
begin
while g.next; end
rescue EOFError
end
Not with magnitudes, tho.
Csaba