while looking at this question C# Similarities of two arrays it was noted that the initial linq call was significantly slower than subsequent calls. What is being cached th
You are enumerating the result of Intersect()
only when you call Count()
; that's when the calculation of the intersection actually occurs. The part you're timing is the creation of the enumerable object that represents the future calculation of the intersection.
In addition to the jitting penalty others have noted, the first call to Intersect()
might be the first use of a type from System.Core.dll, so you might be looking at the time required to load the IL code into memory, as well.