Last active
June 23, 2020 18:18
-
-
Save aalmada/171dac325964abccd8cecb1580174242 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
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Jobs; | |
| using System.Linq; | |
| namespace NetFabric.Hyperlinq.Benchmarks | |
| { | |
| [SimpleJob(RuntimeMoniker.Net472, baseline: true)] | |
| [SimpleJob(RuntimeMoniker.NetCoreApp50)] | |
| [MemoryDiagnoser] | |
| public class RangeContainsBenchmarks | |
| { | |
| [Params(0, 1, 10, 100)] | |
| public int Count { get; set; } | |
| [Benchmark(Baseline = true)] | |
| public bool Condition() | |
| => Count - 1 >= 0 && Count - 1 < Count; | |
| [Benchmark] | |
| public bool Linq() | |
| => Enumerable.Range(0, Count).Contains(Count - 1); | |
| [Benchmark] | |
| public bool Hyperlinq() | |
| => ValueEnumerable.Range(0, Count).Contains(Count - 1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment