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

John Lam (DLR) jflam at microsoft.com
Wed Feb 6 17:58:59 EST 2008


Michael Letterle:

> I have some ideas on what some of the issues may be, primarily related
> to how the Enumerable class creates a new Proc object every time
> through the loop.  Anyway, doing the following seems to help to some
> extent:
>
> require 'mscorlib'
> require 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll'
>
> a = (1..1000).to_a
> s = System::Diagnostics::Stopwatch.new()
> m = Proc.new {|x| x == 1000 }
> 1000.times {
>     s.start
>   y = a.find &m
>     s.stop
>     puts "find took: #{s.elapsed.ToString}"
>     s.reset
> }
>
> find took: 00:00:00.0012998
> find took: 00:00:00.0012719
> find took: 00:00:00.0012915
>
> [snip]
>
> find took: 00:00:00.0049048
> find took: 00:00:00.0052548
> find took: 00:00:00.0051403
>
> [snip]
>
> find took: 00:00:00.0127650
> find took: 00:00:00.0141006
> find took: 00:00:00.0106432

This is a strange; nothing obvious jumps out right now. We'll have to look at this down the road when we do our perf push. Clearly this is a bug. Can someone open up a bug for this?

Thanks,
-John



More information about the Ironruby-core mailing list