Created
May 1, 2024 10:08
-
-
Save sa-es-ir/8f4b15152f13eceb356a45b16762cc08 to your computer and use it in GitHub Desktop.
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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Jobs; | |
namespace Benchmarks; | |
[SimpleJob(RuntimeMoniker.Net80, baseline: true)] | |
[SimpleJob(RuntimeMoniker.Net90)] | |
[MemoryDiagnoser(false)] | |
[HideColumns("RatioSD", "Median", "StdDev", "Error", "Job", "Alloc Ratio")] | |
public class LinqAggregateBenchmark | |
{ | |
[Params(10000)] | |
public int Length { get; set; } | |
private IEnumerable<int> _source; | |
[GlobalSetup] | |
public void Setup() => _source = Enumerable.Range(1, Length); | |
[Benchmark] | |
public int Min() => _source.Min(); | |
[Benchmark] | |
public int Max() => _source.Max(); | |
[Benchmark] | |
public double Average() => _source.Average(); | |
[Benchmark] | |
public int Sum() => _source.Sum(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment