Created
May 25, 2021 16:51
-
-
Save JerryNixon/7c5603ae7549c3b9ab1ca6f358ebb903 to your computer and use it in GitHub Desktop.
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
| public class Program | |
| { | |
| static void Main() | |
| { | |
| BenchmarkRunner.Run<Harness>(); | |
| } | |
| } | |
| public class Harness | |
| { | |
| [Benchmark] | |
| public bool ArrayAny() => _array.Any(); | |
| [Benchmark] | |
| public bool ArrayCount() => _array.Count() > 0; | |
| [Benchmark] | |
| public bool ListAny() => _list.Any(); | |
| [Benchmark] | |
| public bool ListCount() => _list.Count() > 0; | |
| [Benchmark] | |
| public bool EnumerableAny() => _enumerable.Any(); | |
| [Benchmark] | |
| public bool EnumerableCount() => _enumerable.Count() > 0; | |
| public static Guid[] _array | |
| = Enumerable.Range(0, 100_000).Select(x => Guid.NewGuid()).ToArray(); | |
| public static List<Guid> _list | |
| = Enumerable.Range(0, 100_000).Select(x => Guid.NewGuid()).ToList(); | |
| public static IEnumerable<Guid> _enumerable | |
| = Enumerable.Range(0, 100_000).Select(x => Guid.NewGuid()); | |
| } |
JerryNixon
commented
May 25, 2021
Author

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment