From: Ross Bamford Date: 2006-02-15T04:43:10+09:00 Subject: Re: [QUIZ] FasterGenerator (#66) On Wed, 2006-02-15 at 02:54 +0900, Dave Lee wrote: > I hadn't added test_realtime to my test set, but now I have and this > bug is fixed. I have attached the fixed version for anyone who cares. > For the hell of it, I also optimized by manually inlining some method > calls, and eliminating redundant bounds checking. This should now > pass all tests and run much faster. It does pass all the tests (including a new one based on Luke Blanshard's stateful code), but I can't imagine what on earth is going on here (see assertion counts): [rosco@jukebox 66]$ ruby tests.rb davelee_generator.rb Loaded suite tests Started ...... Finished in 1.067421 seconds. 6 tests, 1561 assertions, 0 failures, 0 errors [rosco@jukebox 66]$ ruby tests.rb davelee_generator.rb Loaded suite tests Started ...... Finished in 1.078261 seconds. 6 tests, 422 assertions, 0 failures, 0 errors [rosco@jukebox 66]$ ruby tests.rb davelee_generator.rb Loaded suite tests Started ...... Finished in 1.012041 seconds. 6 tests, 1561 assertions, 0 failures, 0 errors [rosco@jukebox 66]$ ruby tests.rb davelee_generator.rb Loaded suite tests Started ...... Finished in 1.065682 seconds. 6 tests, 682 assertions, 0 failures, 0 errors [rosco@jukebox 66]$ ruby tests.rb davelee_generator.rb Loaded suite tests Started ...... Finished in 1.071149 seconds. 6 tests, 422 assertions, 0 failures, 0 errors It seems to be jumping early out of the endless test judging by the number of missing assertions. It only happens sometimes (1561 is a full pass) and it does happen with the old version too (only just noticed it). I ran updated timings since they don't use endless iterators anyway. Here's the result (on 1.8.4): ### Construction ### Rehearsal ------------------------------------------------------------- New Thread Generator 0.270000 0.050000 0.320000 ( 0.379841) Old callcc Generator 0.290000 0.090000 0.380000 ( 0.381635) RossBamfordGenerator 1.150000 0.060000 1.210000 ( 1.269793) JesseYoonGenerator 2.700000 0.100000 2.800000 ( 2.797546) JacobFugalGenerator 0.020000 0.000000 0.020000 ( 0.022782) JEGIIGenerator 0.010000 0.000000 0.010000 ( 0.008398) HorndudeGenerator 1.290000 0.020000 1.310000 ( 1.308930) DaveLeeGenerator 0.010000 0.000000 0.010000 ( 0.007556) ChristofferLernoGenerator 0.000000 0.000000 0.000000 ( 0.004950) CalebClausenSyncGenerator 3.610000 0.070000 3.680000 ( 3.696594) CalebClausenGenerator 7.940000 0.130000 8.070000 ( 8.151407) --------------------------------------------------- total: 17.810000sec user system total real New Thread Generator 5.050000 0.090000 5.140000 ( 5.184013) Old callcc Generator 0.100000 0.080000 0.180000 ( 0.183245) RossBamfordGenerator 6.490000 0.050000 6.540000 ( 6.663615) JesseYoonGenerator 8.170000 0.110000 8.280000 ( 8.356455) JacobFugalGenerator 0.040000 0.000000 0.040000 ( 0.150496) JEGIIGenerator 0.000000 0.000000 0.000000 ( 0.003616) HorndudeGenerator 2.310000 0.020000 2.330000 ( 2.325253) DaveLeeGenerator 0.010000 0.000000 0.010000 ( 0.010512) ChristofferLernoGenerator 0.000000 0.000000 0.000000 ( 0.004091) CalebClausenSyncGenerator 10.320000 0.160000 10.480000 ( 10.493258) CalebClausenGenerator 15.580000 0.190000 15.770000 ( 15.832376) ### next() ### Rehearsal ------------------------------------------------------------- New Thread Generator 0.560000 0.000000 0.560000 ( 0.618782) Old callcc Generator 1.670000 0.330000 2.000000 ( 2.090583) RossBamfordGenerator 0.560000 0.010000 0.570000 ( 0.634513) JesseYoonGenerator 1.960000 0.010000 1.970000 ( 2.037655) JacobFugalGenerator 0.520000 0.000000 0.520000 ( 0.568505) JEGIIGenerator 0.040000 0.000000 0.040000 ( 0.124053) HorndudeGenerator 0.020000 0.000000 0.020000 ( 0.054959) DaveLeeGenerator 0.030000 0.000000 0.030000 ( 0.080798) ChristofferLernoGenerator 0.060000 0.000000 0.060000 ( 0.123206) CalebClausenSyncGenerator 0.740000 0.010000 0.750000 ( 0.801426) CalebClausenGenerator 0.490000 0.000000 0.490000 ( 0.561398) ---------------------------------------------------- total: 7.010000sec user system total real New Thread Generator 0.550000 0.000000 0.550000 ( 0.561499) Old callcc Generator 1.740000 0.060000 1.800000 ( 1.809145) RossBamfordGenerator 0.560000 0.000000 0.560000 ( 0.558627) JesseYoonGenerator 1.610000 0.010000 1.620000 ( 1.626749) JacobFugalGenerator 0.500000 0.010000 0.510000 ( 0.501115) JEGIIGenerator 0.040000 0.000000 0.040000 ( 0.043879) HorndudeGenerator 0.010000 0.000000 0.010000 ( 0.007551) DaveLeeGenerator 0.040000 0.010000 0.050000 ( 0.034707) ChristofferLernoGenerator 0.060000 0.000000 0.060000 ( 0.064452) CalebClausenSyncGenerator 0.750000 0.000000 0.750000 ( 0.754337) CalebClausenGenerator 0.530000 0.010000 0.540000 ( 0.533183) -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk