[Ironruby-core] Weird performance problem with "find"

M. David Peterson m.david at xmlhacker.com
Wed Feb 6 15:31:54 EST 2008


On Wed, 06 Feb 2008 13:23:10 -0700, Michael Letterle  
<michael.letterle at gmail.com> wrote:

> He's right about the issue however:
> ...
> find took: 00:00:00.0377458
> find took: 00:00:00.0453373
> find took: 00:00:00.0369415

Whoops.  My bad.  I was testing via Ruby.NET which, coincidentally,  
doesn't showcase this type of behavior,

find took: 00:00:00.0216940
find took: 00:00:00.0012342
find took: 00:00:00.0012423
...
find took: 00:00:00.0013994
find took: 00:00:00.0013016
find took: 00:00:00.0017697
...
find took: 00:00:00.0012989
find took: 00:00:00.0014228
find took: 00:00:00.0013389
...

I guess maybe Ruby.NET still has its place in this world afterall. ;-) :D

---

(the modified code in case anyone wants to run the comparison on their own  
machine)

require 'mscorlib'
require 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll'

a = (1..1000).to_a
s = System::Diagnostics::Stopwatch.new()

100.times {
     s.Start
     a.find {|x| x == 1000}
     s.Stop
     puts "find took: #{s.Elapsed}"
     s.Reset
}

-- 
/M:D

M. David Peterson
Co-Founder & Chief Architect, 3rd&Urban, LLC
Email: m.david at 3rdandUrban.com | m.david at amp.fm
Mobile: (206) 418-9027
http://3rdandUrban.com | http://amp.fm |  
http://www.oreillynet.com/pub/au/2354


More information about the Ironruby-core mailing list