I am working on a code base with a lot of ForEach... If's. I was planning to convert them to filtered for each’s but I wanted to know is the speed improvement worth the time. I know all of these things are relative but if the filtered for each is magnitudes faster in general it would make sense to change.
For Each egg In chicken.Where(Function(x) x.Tasty = True)
' Do Stuff
Next
For Each egg In chicken
If x.Tasty = True Then
' Do Stuff
End If
Next
One thing you could try is use the StopWatch class to measure how long each
Forloop takes e.g.