-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathProgram.cs
37 lines (29 loc) · 867 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Made by Benjamin Abt - https://github.com/BenjaminAbt
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<Benchmark>();
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net70)] // PGO enabled by default
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[HideColumns(Column.Job)]
public class Benchmark
{
private List<int> _list;
[Params(0, 1, 10, 100)]
public int Items { get; set; }
[GlobalSetup]
public void GlobalSetup()
{
IEnumerable<int> range = Enumerable.Range(0, Items);
_list = range.ToList();
}
[Benchmark(Baseline = true)]
public bool Any() => _list.Any();
[Benchmark]
public bool Count() => _list.Count > 0;
}