From: Eric Wong Date: 2013-08-26T21:58:17+00:00 Subject: [ruby-core:56815] Re: [ruby-trunk - Feature #8820][Open] Speed up Array#index Joel VanderWerf wrote: > On 08/26/2013 12:57 PM, Eric Wong wrote: > >The performance of your code varies between runs because the > >ordering is always different and index is O(n) _worst_ case. > >call srand(0) before any rand calls to get a consistent seed. > > The running time of this code won't vary much at all. The n=10000000 > setting is much higher than a.size, so most #index calls will return > nil. The entire array is searched for almost all iterations. I think you're right. I was on a new machine (Haswell) and enabled a bunch kernel options I normally don't use (Hyper-threading, full tickless, full preempt, automatic process group scheduling). Lots of variables even when the system isn't loaded :o