Last active
August 29, 2015 14:20
-
-
Save naveensrinivasan/9153a580b7f4bda55a38 to your computer and use it in GitHub Desktop.
Measuring LINQ Any operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var useAny = false; | |
var loremipsum = @"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo | |
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, | |
nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. | |
Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, | |
arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu | |
pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean | |
vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, | |
enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a,"; | |
var items = loremipsum.Split(new [] {' '}).Distinct().ToList(); | |
var lookfor = "pede"; | |
var runPerf =new Action( () => { | |
if (!useAny) | |
{ | |
foreach (var item in items) | |
{ | |
if (item == lookfor) { | |
return; | |
} | |
} | |
} | |
else | |
{ | |
items.Any (i => i == lookfor); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment