Ok, i've found the main cause of the issue: The problem is that comparing
strings using the current culture (which is what the instance method of
string.Compare does) is incredibly slow.

To verify this, just change the code in 'DictionaryValue' to do it's
comparision using the StringComparer.Ordinal. Using
StringComparer.CurrentCulture results in the same slow behavior as the
instance method on string does.

Alan.

On Jan 4, 2008 6:58 PM, Alan McGovern <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I really doubt that calling the Key, Value overload would give that much
> of a slowdown. I'd believe a slowdown of 10%, or maybe 15%, but not 600%.
> I'd say the slowdown is due to an inefficient algorithm as opposed to
> anything else.
>
> Alan.
>
>
> On Jan 4, 2008 3:35 PM, Juraj Skripsky <[EMAIL PROTECTED]> wrote:
>
> > I've filed a bug report for this:
> > https://bugzilla.novell.com/show_bug.cgi?id=351638
> >
> > - Juraj
> >
> > On Fri, 2008-01-04 at 16:10 +0100, Juraj Skripsky wrote:
> > > I've found one potential problem in Array.Sort<T> (called by
> > > List<T>.Sort) that could account for quite some slowdown.
> > >
> > > All of the following "Sort<T>" method overloads call a "Sort<TKey,
> > > TValue>" overload with null as the values/items array to get their
> > work
> > > done:
> > >
> > > public static void Sort<T> (T [] array)
> > > public static void Sort<T> (T [] array, IComparer<T> comparer)
> > > public static void Sort<T> (T [] array, int index, int length)
> > > public static void Sort<T> (T [] array, int index, int length,
> > > IComparer<T> comparer)
> > >
> > > This is suboptimal as those methods in turn use the swap<K, V> method
> > > which needs to check (and then ignore) the values/items array.
> > >
> > > So we're push popping a lot of unnecessary nulls on and off the stack
> > > and checking them. And as swap<T> is a lot smaller than swap<K, V> its
> > > chances for being inlined by the JIT compiler are much higher.
> > >
> > > - Juraj
> >
> >
> >
>
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to