[Mono-list] Speed difference Windows - Linux
Alan McGovern
alan.mcgovern at gmail.com
Fri Jan 4 15:18:37 EST 2008
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 <alan.mcgovern at gmail.com> 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 <js at hotfeet.ch> 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
> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080104/354f422c/attachment.html
More information about the Mono-list
mailing list