This project is read-only.

Inconsistent Result

Mar 6, 2009 at 3:55 PM
So I am a little confused.  I am getting inconsistent result.

You can prove this in the using the TestDynamicCreateIndexFor test.  Switch the order of the 2 linq statments(indexed query first)

indexedStopwatch.Start(); var indexedQuery = from item in list
where item.DemoStringIndexed == indexedString
select item;
var resultIndexed = indexedQuery.ToList();

nonIndexedStopwatch.Start(); var nonIndexedQuery = from item in list
where item.DemoStringNonIndexed == nonIndexedString
select item;
var resultNonIndexed = nonIndexedQuery.ToList();

When I try switching the queries in the demo app the index is still faster.
Any ideas why?
How much testing have you done with ordering of indexed/non-indexed queries and the types of the collestions being compared.

Mar 7, 2009 at 1:12 AM
I see what you are questioning.

I just ran both scenerios through Ants profiler and in both cases all the time is spent on the first call to xxx.ToList().

I'm currently stumpped...
Mar 7, 2009 at 12:55 PM
I would strictly put the timer on the ToList call - that is the only thing that is going to take real time.  Creating the query doesn't iterate over anything, and will have insignificant time.

Also, for a small set, the difference will be unsubstantial.  It really does not express well until you get to around >5000 items in a list.