-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfig.cs
More file actions
86 lines (70 loc) · 2.64 KB
/
Config.cs
File metadata and controls
86 lines (70 loc) · 2.64 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
82
83
84
85
86
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Validators;
namespace Hyperbee.Json.Benchmark;
public class Config : ManualConfig
{
public Config()
{
AddJob( Job.ShortRun
.WithRuntime( CoreRuntime.Core90 )
.WithId( ".NET 8" ) );
AddJob( Job.ShortRun
.WithRuntime( CoreRuntime.Core90 )
.WithId( ".NET 9" ) );
AddJob( Job.ShortRun
.WithRuntime( CoreRuntime.Core10_0 )
.WithId( ".NET 10" ) );
AddValidator( JitOptimizationsValidator.DontFailOnError );
AddLogger( ConsoleLogger.Default );
AddColumnProvider(
DefaultColumnProviders.Job,
DefaultColumnProviders.Params,
DefaultColumnProviders.Descriptor,
DefaultColumnProviders.Metrics,
DefaultColumnProviders.Statistics
);
// Customize the summary style to prevent truncation
WithSummaryStyle( SummaryStyle.Default.WithMaxParameterColumnWidth( 100 ) );
// Add the custom exporter with specified visible columns
AddExporter( new JsonPathMarkdownExporter
{
ShowColumn = column =>
{
return column.OriginalColumn.ColumnName switch
{
"Method" => true,
"Mean" => true,
"Error" => true,
"StdDev" => true,
"Allocated" => true,
_ => false
};
}
} );
AddDiagnoser( MemoryDiagnoser.Default );
Orderer = new FastestToSlowestByParamOrderer();
// Set the artifacts path to a specific directory in the project
// Set the artifacts path to a specific directory in the project
var projectFolder = FindParentFolder( "Hyperbee.Json.Benchmark" );
ArtifactsPath = System.IO.Path.Combine( projectFolder, "benchmark" );
}
private static string FindParentFolder( string target )
{
var currentDirectory = new DirectoryInfo( AppContext.BaseDirectory );
while ( currentDirectory != null )
{
if ( currentDirectory.Name.Equals( target, StringComparison.OrdinalIgnoreCase ) )
{
return currentDirectory.FullName;
}
currentDirectory = currentDirectory.Parent;
}
throw new DirectoryNotFoundException( $"Could not find the target folder '{target}' in the directory tree." );
}
}