-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathIntroOrderManual.cs
More file actions
59 lines (49 loc) · 2.2 KB
/
IntroOrderManual.cs
File metadata and controls
59 lines (49 loc) · 2.2 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Order;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
namespace BenchmarkDotNet.Samples
{
[Config(typeof(Config))]
[DryJob]
[UseLocalJobOnly]
[RankColumn]
public class IntroOrderManual
{
private class Config : ManualConfig
{
public Config() => Orderer = new FastestToSlowestOrderer();
private class FastestToSlowestOrderer : IOrderer
{
public IEnumerable<BenchmarkCase> GetExecutionOrder(ImmutableArray<BenchmarkCase> benchmarksCase,
IEnumerable<BenchmarkLogicalGroupRule>? order = null) =>
from benchmark in benchmarksCase
orderby benchmark.Parameters["X"] descending,
benchmark.Descriptor.WorkloadMethodDisplayInfo
select benchmark;
public IEnumerable<BenchmarkCase> GetSummaryOrder(ImmutableArray<BenchmarkCase> benchmarksCase, Summary summary) =>
from benchmark in benchmarksCase
orderby summary[benchmark]?.ResultStatistics?.Mean
select benchmark;
public string? GetHighlightGroupKey(BenchmarkCase benchmarkCase) => null;
public string GetLogicalGroupKey(ImmutableArray<BenchmarkCase> allBenchmarksCases, BenchmarkCase benchmarkCase) =>
benchmarkCase.Job.DisplayInfo + "_" + benchmarkCase.Parameters.DisplayInfo;
public IEnumerable<IGrouping<string, BenchmarkCase>> GetLogicalGroupOrder(IEnumerable<IGrouping<string, BenchmarkCase>> logicalGroups,
IEnumerable<BenchmarkLogicalGroupRule>? order = null) =>
logicalGroups.OrderBy(it => it.Key);
public bool SeparateLogicalGroups => true;
}
}
[Params(1, 2, 3)]
public int X { get; set; }
[Benchmark]
public void Fast() => Thread.Sleep(X * 50);
[Benchmark]
public void Slow() => Thread.Sleep(X * 100);
}
}