On Feb 10, 2006, at 10:08 AM, Matthew Moss wrote:

> Not being familiar with all the various Ruby packages and libs, I
> first want to thank ya for posting a good set of test cases that I can
> review, but was wondering if you also might post the code used to do
> the timing?

I will, yes, on Sunday.  :)

I pulled down copies on the Generator library, before and after the  
change.  I then modified the class names so they could all peacefully  
coexist, loaded them, and ran a trivial benchemark:

#!/usr/local/bin/ruby -w

require "benchmark"

require "current_generator"
require "callcc_generator"
require "faster_generator"

tests = 1000
enum  = (1..10000).to_a

puts
puts "### Construction ###"
puts

Benchmark.bmbm do |x|
   x.report("Current Generator") do
     tests.times { CurrentGenerator.new(enum) }
   end
   x.report("Old callcc Generator") do
     tests.times { CallCCGenerator.new(enum) }
   end
   x.report("James's FasterGenerator") do
     tests.times { FasterGenerator.new(enum) }
   end
end

puts
puts "### next() ###"
puts

Benchmark.bmbm do |x|
   x.report("Current Generator") do
     generator = CurrentGenerator.new(enum)
     tests.times { generator.next until generator.end? }
   end
   x.report("Old callcc Generator") do
     generator = CallCCGenerator.new(enum)
     tests.times { generator.next until generator.end? }
   end
   x.report("James's FasterGenerator") do
     generator = FasterGenerator.new(enum)
     tests.times { generator.next until generator.end? }
   end
end

__END__

I'll post the modified libraries to go with that after the spoiler  
period.  Obviously, you could go get them yourself, before then.  I  
strongly recommend writing a solution first though.

James Edward Gray II