1- using BenchmarkDotNet . Configs ;
1+ using BenchmarkDotNet . Attributes ;
2+ using BenchmarkDotNet . Configs ;
3+ using BenchmarkDotNet . Diagnosers ;
24using BenchmarkDotNet . Engines ;
3- using BenchmarkDotNet . Jobs ;
5+ using BenchmarkDotNet . Exporters ;
46using BenchmarkDotNet . Loggers ;
57using BenchmarkDotNet . Reports ;
68using BenchmarkDotNet . Running ;
7- using BenchmarkDotNet . Toolchains . InProcess . Emit ;
89using System ;
910using System . Collections . Generic ;
1011using System . Linq ;
@@ -26,12 +27,7 @@ public static int Main(string[] args)
2627 ConsoleLogger . Default . WriteLine ( ) ;
2728 }
2829
29- IConfig config ;
30- #if DEBUG
31- config = GetDebugConfig ( ) ;
32- #else
33- config = null ; // `DefaultConfig.Instance` is used.
34- #endif
30+ IConfig ? config = GetConfig ( ref args ) ;
3531
3632 var summaries = BenchmarkSwitcher . FromAssembly ( typeof ( Program ) . Assembly )
3733 . Run ( args , config )
@@ -43,17 +39,29 @@ public static int Main(string[] args)
4339 return 0 ;
4440 }
4541
46- private static ManualConfig GetDebugConfig ( )
42+ private static IConfig ? GetConfig ( ref string [ ] args )
4743 {
48- return DefaultConfig . Instance
49- . WithOptions ( ConfigOptions . DisableOptimizationsValidator )
50- . WithOptions ( ConfigOptions . StopOnFirstError )
51- . AddJob (
52- Job . Default
53- . WithId ( "WithDebugConfiguration" )
54- . WithToolchain ( InProcessEmitToolchain . Instance )
55- . WithStrategy ( RunStrategy . Monitoring )
56- ) ;
44+ #if ! DEBUG
45+ return null ; // `DefaultConfig.Instance` is used.
46+ #else
47+ bool isInProcess = args . Contains ( "--inProcess" ) ;
48+ if ( isInProcess )
49+ args = args . Where ( x => x != "--inProcess" ) . ToArray ( ) ;
50+
51+ DebugConfig config = isInProcess
52+ ? new DebugInProcessConfig ( )
53+ : new DebugBuildConfig ( ) ;
54+
55+ return config . AddAnalyser ( DefaultConfig . Instance . GetAnalysers ( ) . ToArray ( ) )
56+ . AddDiagnoser (
57+ MemoryDiagnoser . Default ,
58+ new ExceptionDiagnoser ( new ExceptionDiagnoserConfig ( displayExceptionsIfZeroValue : false ) ) ,
59+ new ThreadingDiagnoser ( new ThreadingDiagnoserConfig ( displayCompletedWorkItemCountWhenZero : false , displayLockContentionWhenZero : false ) )
60+ )
61+ . AddExporter ( MarkdownExporter . Default )
62+ . AddValidator ( DefaultConfig . Instance . GetValidators ( ) . ToArray ( ) )
63+ . WithArtifactsPath ( DefaultConfig . Instance . ArtifactsPath ) ;
64+ #endif
5765 }
5866}
5967
0 commit comments