tags:

views:

91

answers:

2

Can anyone explain the reasons the numbers in this post are the way they are?

http://stackoverflow.com/questions/454916/performance-of-arrays-vs-lists

I was curious why the iterator for list performs so poorly but the for indexer was so close.

+1  A: 

There's probably very little in the way of the List indexer and the array indexer so it makes sense that they're very close in timing (i.e., the list implementation chains to the array implementation with not much if anything in-between).

I'm guessing on the iterator, but the List implementation would need to check for error conditions such as concurrent modification and bounds violations. It's probably written with a yield as well. These would have a small impact, but we're talking micro-differences here.

To really answer this, you could step into the framework source via the source code reference server.

Rob
A: 

It isn't clear from your question which results you are referring to, but I'll assume it's Marc's analysis (the currently accepted answer). Looking at the comments in both his answer and some of the other answers, there seems to be some uncertainty about the results.

Scott Dorman