J
jehugaleahsa
Hello:
I was running some tests today and found an interesting result. I have
a large library where half the methods work on IEnumerable<T>
(Iterators similar to LINQ), and another that works on List<T>, using
indices to overwrite values.
I wanted to see which performed better overall (I guessed wrong). What
surprised me what that a well-written Iterator typically ran faster
(usually generating a new IEnumerable<U>) than a similar method that
just overwrites a List<T>.
Does anyone have a good explanation for why this is true? Is it just a
fluke on my part? And what does the community say about using one over
the other? I honestly think there is something beautiful about
Iterators and would like to use them more often than not.
Thanks for your input,
Travis
I was running some tests today and found an interesting result. I have
a large library where half the methods work on IEnumerable<T>
(Iterators similar to LINQ), and another that works on List<T>, using
indices to overwrite values.
I wanted to see which performed better overall (I guessed wrong). What
surprised me what that a well-written Iterator typically ran faster
(usually generating a new IEnumerable<U>) than a similar method that
just overwrites a List<T>.
Does anyone have a good explanation for why this is true? Is it just a
fluke on my part? And what does the community say about using one over
the other? I honestly think there is something beautiful about
Iterators and would like to use them more often than not.
Thanks for your input,
Travis