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

Eric Nicholson enicholson at gmail.com
Wed Feb 6 14:38:46 EST 2008


I noticed some strange issues in an application I'm working on where it
works speedy at first, and then gets progressively slower and slower.  After
a little bit of investigation, it seems that Enumerable#find is the
culprit.  The more times you run a find statement the slower it gets.  Does
anybody have any ideas why this is?

Here's a sample that demonstrates the issue:

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.ToString}"
}

which outputs:

find took: 00:00:00.0743446
...snip...
find took: 00:00:00.2290894
...snip...
find took: 00:00:00.4942105

I understand you guys aren't optimizing yet, but I thought you might be
interested to see growth where there shouldn't be any.  Also, if you have
any ideas off the top of your head, I wouldn't mind looking into it a
little.

-Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20080206/db2837b1/attachment.html 


More information about the Ironruby-core mailing list