[Mono-list] List.FindAll method implementation

Juan C. Olivares juancri at gmail.com
Sun Mar 18 16:58:45 EDT 2007


HI all:

I was reading Ben Maurer's comments in
mcs/class/corlib/System.Collections.Generic/List.cs :: FindAll (Predicate):

*// Maybe we could make this faster. For example, you could
**// make a bit set with stackalloc for which elements to copy
**// then you could size the array correctly.
*

I did some testing:

http://www.juancri.com/archivos/listfindall.cs.txt

Compile it with -unsafe.

I think the Find2 method is the correct one. These are my results:

100 initial items:
Old method: 00:00:00.0170850: found 96 elements
stackalloc bool method: 00:00:00.0005240: found 96 elements
stackalloc bit method: 00:00:00.0012710: found 96 elements
bool array method: 00:00: 00.0013550: found 96 elements


1,000 initial items:
Old method: 00:00:00.0191490: found 492 elements
stackalloc bool method: 00:00:00.0006480: found 492 elements
stackalloc bit method: 00:00:00.0016600: found 492 elements
bool array method: 00:00:00.0009650: found 492 elements

10,000 initial items:
Old method: 00:00: 00.0146590: found 6383 elements
stackalloc bool method: 00:00:00.0014510: found 6383 elements
stackalloc bit method: 00:00:00.0023390: found 6383 elements
bool array method: 00:00:00.0021090: found 6383 elements

100,000 initial items:
Old method: 00:00:00.0264500: found 40134 elements
stackalloc bool method: 00:00:00.0117350: found 40134 elements
stackalloc bit method: 00:00: 00.0135060: found 40134 elements
bool array method: 00:00:00.0100860: found 40134 elements

Do you have any comment?. I could send a patch...

best regards

Juan C. Olivares
www.juancri.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070318/4f906eb5/attachment.html 


More information about the Mono-list mailing list