Collection Performance: Looping Over Collection – Array vs. List

Updated January 2024

Most of the benchmarks in this book that test a collection are performed using List<> with a real-world business object Person as a reference type. I was curious about how that would compare to using an array of Person.

Benchmark Results

Here are the benchmark results for iterating over an Array compared to a List<> collection of reference types using for() and foreach().

As evident from these results, utilizing an array is 7.5 times faster.

As evident from these results, using an array is 7.6 times faster.

Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks

If you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave

© The information in this article is copywritten and cannot be reproduced in any way without express permission from David McCarter.


Discover more from dotNetTips.com

Subscribe to get the latest posts sent to your email.

One thought on “Collection Performance: Looping Over Collection – Array vs. List

Leave a Reply