-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cs
More file actions
81 lines (70 loc) · 3.18 KB
/
Config.cs
File metadata and controls
81 lines (70 loc) · 3.18 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Collections.Immutable;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Order;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.NativeAot;
using Perfolizer.Horology;
using Perfolizer.Mathematics.OutlierDetection;
namespace Benchmarks;
public class Config : ManualConfig {
public Config() {
UnionRule = ConfigUnionRule.AlwaysUseLocal;
SummaryStyle = SummaryStyle.Default.WithRatioStyle(RatioStyle.Trend);
AddDiagnoser(MemoryDiagnoser.Default);
var baseJob = Job.Default
.WithId("PGO1")
.WithOutlierMode(OutlierMode.RemoveAll)
.WithLaunchCount(3)
.WithWarmupCount(5)
.WithIterationCount(30)
.WithIterationTime(TimeInterval.FromMilliseconds(100))
.WithEnvironmentVariable("DOTNET_TieredPGO", "1"); // default, explicit for clarity
AddJob(baseJob);
AddJob(baseJob
.WithId("PGO2")
.WithEnvironmentVariable("DOTNET_TieredPGO", "2"));
AddJob(baseJob
.WithId("NativeAOT")
.WithEnvironmentVariable("DOTNET_TieredPGO", "0") // not applicable, but keep deterministic
.WithToolchain(NativeAotToolchain.Net10_0));
AddColumnProvider(DefaultColumnProviders.Instance);
HideColumns(Column.Error, Column.StdDev, Column.Median, Column.RatioSD);
WithOrderer(new GroupByTypeOrderer());
WithOptions(ConfigOptions.JoinSummary);
WithOptions(ConfigOptions.StopOnFirstError);
WithOptions(ConfigOptions.DisableLogFile);
AddExporter(MarkdownExporter.GitHub);
AddLogger(ConsoleLogger.Default);
}
}
internal sealed class GroupByTypeOrderer : IOrderer {
// Keep execution order as-declared (you can customize if you want)
public IEnumerable<BenchmarkCase> GetExecutionOrder(
ImmutableArray<BenchmarkCase> benchmarksCase,
IEnumerable<BenchmarkLogicalGroupRule>? order = null)
=> benchmarksCase;
// Sort rows in the summary: first by Type, then Method, then Params
public IEnumerable<BenchmarkCase> GetSummaryOrder(
ImmutableArray<BenchmarkCase> cases, Summary summary) =>
cases.OrderBy(c => c.Job.Id)
.ThenBy(c => c.Descriptor.Type.FullName)
.ThenBy(c => c.Parameters.DisplayInfo);
// We don’t use highlight groups
public string? GetHighlightGroupKey(BenchmarkCase benchmarkCase) => null;
// Tell BDN how to “group” rows in a joined summary (the section separator)
public string GetLogicalGroupKey(
ImmutableArray<BenchmarkCase> all, BenchmarkCase benchmarkCase)
=> benchmarkCase.Descriptor.Type.FullName!;
// Order the groups themselves (by class name)
public IEnumerable<IGrouping<string, BenchmarkCase>> GetLogicalGroupOrder(
IEnumerable<IGrouping<string, BenchmarkCase>> logicalGroups,
IEnumerable<BenchmarkLogicalGroupRule>? order = null)
=> logicalGroups.OrderBy(g => g.Key);
public bool SeparateLogicalGroups => true;
}