From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-05-31T14:55:36+09:00 Subject: Re: Array.extend versus instance.extend On Sat, 31 May 2003 14:26:53 +0900, Guillaume Marcais wrote: > OK, my fault. The following code should pass your test and *is* faster > most of the time. Pop_until, because of the reverse, is slower when the > search ends early. Yes now it works.. I am not yet 100% familiar with the 'or' thing. I would definitly not have found out that myself. Thanks for new knowledge. > module ArrayMisc2 > def shift_until(klass) > p = -1 > detect { |x| p += 1; klass === x } or p += 1 > slice!(0, p) > end > def pop_until(klass) > p = -1 > reverse.detect { |x| p += 1; klass === x } or p += 1 > slice!(-p, p) > end > end This 'detectj+slice' concept is good.. reduces the number of temporary objects a lot. I have completely adapted it. > speed_test(a, max, ArrayMisc, ArrayMisc2) [snip results data] Nice speed comparison.. you have improved it further, so that the results is 2 adjacent columns :-) BTW: Is there any speed-testing frameworks around ? -- Simon Strandgaard