Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 1.09 KB

README.md

File metadata and controls

12 lines (7 loc) · 1.09 KB

IterateOverCollectionTests

Used for testing different methods of iterating over a collection that has items periodically added and removed

image

Summary: Using a List and for loop is fastest. Adding an object pool will slightly slow it down but drastically save on memory allocations and garbage collections.

image

image

Looking at the dotTrace graph the List and for loop looks really good because it's less than 5% of the GC but that's only because the foreach loop is so bad. When running dotTrace for just the ListAndForLoop with and without object pooling it shows 100% of GCs and memory allocations going to without a pool. 183 GCs vs 0 in a ~10 second period. Object pooling look very worth doing for short duration classes like projectiles, ai tasks, naviation tasks, and so on.