Performance question with Find

Posts   
 
    
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 08-Jul-2005 22:13:09   

What is this doing internally?

    Public Shared Function FindGroupStudentByStudentIdent(ByVal groupStudentCollection As EntityCollection, ByVal studentIdent As Integer) As Integer
        Dim i As Integer

        i = groupStudentCollection.Find(New EntityPropertyDescriptor2(EntityFieldFactory.Create(Elementary.GradeBook.LLBL.GroupStudentFieldIndex.StudentIdent), _
          GetType(GroupStudentEntity), False), studentIdent)

        Return i
    End Function

Is it looping thru the collection until it finds a match or is it faster then that?

Thanks,

Fishy

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Jul-2005 23:24:01   

It loops with a forloop and performs a linear search, using .Equals(). simple_smile This is similar to performing IndexOf for example in a collection which also performs a linear search.

Frans Bouma | Lead developer LLBLGen Pro
swallace
User
Posts: 648
Joined: 18-Aug-2003
# Posted on: 09-Jul-2005 05:07:50   

Sometimes when I need to know what a compiled .NET dll is doing internally, I use Lutz Roeder's Reflector for .NET, available at:

http://www.aisto.com/roeder/dotnet/

It offers a 'decompilation' view of functions so you can see what's happening internally. Pretty nifty.