[Mono-dev] List<T> Optimisations
Alan McGovern
alan.mcgovern at gmail.com
Mon Mar 26 12:24:26 EDT 2007
Attached is a newer patch which removes the use of: "this." as it's against
the mono coding guidelines.
Alan.
On 3/26/07, Alan McGovern <alan.mcgovern at gmail.com> wrote:
>
> I was just browsing through the List<T> implementation and made a few
> speed optimisations. I'm not sure if changing from foreach(blah) to for(int
> i=0; i< blah, i++) is ok or not, but it does offer a large speed increase.
> So let me know if that's ok or not.
>
> Optimised Methods:
> RemoveAll - from 0x up to 50x faster
>
> (The reason for the huge speed increase is that if you have a list<int>
> containing entirely the number 5, removing from the end will be much more
> efficient than removing from the start as you won't have to shift the entire
> array over and over. Removing from the end will *always* be faster than
> removing from the start, but the exact speed increase is highly dependant on
> the number of matches).
>
> Add - 0.3x faster
>
> ConvertAll - 0.5x faster
>
> Exists - 0.04x faster
>
> Find - 0.05x faster
>
> ForEach - 2.7x faster
>
> InsertAt - up to 0.2x faster (if addind at the end)
>
> RemoveAll - 0.11x faster
>
> True For All - 2.3x faster
>
> Patch attached. Let me know if it's good to commit. It still passes the
> NUnit tests.
>
> Alan.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070326/95cf6dac/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ListT.patch
Type: text/x-patch
Size: 4058 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070326/95cf6dac/attachment.bin
More information about the Mono-devel-list
mailing list