Created
June 30, 2017 02:18
-
-
Save Kimserey/ac593675ee038b4978cee9d7cdb0f666 to your computer and use it in GitHub Desktop.
Distinct.Any
This file contains hidden or 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
using System; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Threading; | |
namespace DistinctAny | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var evaluation = "A"; | |
var stw = Stopwatch.StartNew(); | |
Console.WriteLine("Start Y1"); | |
var y1 = new[] { "A", "A", "A", "A", "B" } | |
.Any(i => | |
{ | |
Thread.Sleep(1000); | |
return i == evaluation; | |
}); | |
Console.WriteLine("Y1 completed {0}", stw.ElapsedMilliseconds); | |
stw.Restart(); | |
Console.WriteLine("Start Y2"); | |
var y2 = new[] { "A", "A", "A", "A", "B" } | |
.Distinct() | |
.Any(i => | |
{ | |
Thread.Sleep(1000); | |
return i == evaluation; | |
}); | |
Console.WriteLine("Y2 completed {0}", stw.ElapsedMilliseconds); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: