11using System ;
22using System . Globalization ;
33using System . Runtime . CompilerServices ;
4+ using System . Text . RegularExpressions ;
45using System . Threading ;
56using ApprovalTests ;
67using ApprovalTests . Namers ;
78using ApprovalTests . Reporters ;
89using BenchmarkDotNet . Attributes ;
10+ using BenchmarkDotNet . Columns ;
911using BenchmarkDotNet . Configs ;
12+ using BenchmarkDotNet . ConsoleArguments ;
13+ using BenchmarkDotNet . Engines ;
1014using BenchmarkDotNet . Environments ;
1115using BenchmarkDotNet . Exporters ;
1216using BenchmarkDotNet . Jobs ;
1317using BenchmarkDotNet . Loggers ;
1418using BenchmarkDotNet . Tests . Mocks ;
19+ using BenchmarkDotNet . Tests . XUnit ;
1520using BenchmarkDotNet . Toolchains . InProcess . Emit ;
1621using JetBrains . Annotations ;
1722using Xunit ;
@@ -83,5 +88,61 @@ public class BenchmarkClass
8388 {
8489 [ Benchmark ] public void Method ( ) { }
8590 }
91+
92+ [ FactDotNetCoreOnly ( "In the .Net Framework cmd job uses CsProjClassicNetToolchain while fluent and attribute jobs use RoslynToolchain by default" ) ]
93+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
94+ public void MultipleInputColumnsDisplayTest ( )
95+ {
96+ var cmdConfig = ConfigParser . Parse (
97+ "--join --runtimes net481 net6.0 nativeaot6.0" . Split ( ) , NullLogger . Instance ) . config ;
98+
99+ var fluentConfig = ManualConfig . CreateEmpty ( ) . AddColumnProvider ( DefaultColumnProviders . Instance )
100+ . AddJob ( Job . Dry . WithRuntime ( CoreRuntime . Core60 ) )
101+ . AddJob ( Job . Dry . WithRuntime ( ClrRuntime . Net481 ) )
102+ . AddJob ( Job . Dry . WithRuntime ( NativeAotRuntime . Net60 ) ) ;
103+
104+ var config = ManualConfig . Union ( cmdConfig , fluentConfig ) ;
105+
106+ NamerFactory . AdditionalInformation = nameof ( MultipleInputColumnsDisplayTest ) ;
107+ Thread . CurrentThread . CurrentCulture = CultureInfo . InvariantCulture ;
108+
109+ var logger = new AccumulationLogger ( ) ;
110+ logger . WriteLine ( "=== " + nameof ( MultipleInputColumnsDisplayTest ) + " ===" ) ;
111+
112+ var exporter = MarkdownExporter . Mock ;
113+ var summary = MockFactory . CreateSummary < BenchmarkClass1 > ( config ) ;
114+ exporter . ExportToLog ( summary , logger ) ;
115+
116+ var log = logger . GetLog ( ) ;
117+ log = ReplaceRandomIDs ( log ) ;
118+ Approvals . Verify ( log ) ;
119+ }
120+
121+ private static string ReplaceRandomIDs ( string log )
122+ {
123+ var regex = new Regex ( @"Job-\w*" ) ;
124+
125+ var index = 0 ;
126+ foreach ( Match match in regex . Matches ( log ) )
127+ {
128+ var randomGeneratedJobName = match . Value ;
129+
130+ // JobIdGenerator.GenerateRandomId() generates Job-ABCDEF
131+ // respect the length for proper table formatting
132+ var persistantName = $ "Job-rndId{ index } ";
133+ log = log . Replace ( randomGeneratedJobName , persistantName ) ;
134+ index ++ ;
135+ }
136+
137+ return log ;
138+ }
139+
140+ [ SimpleJob ( RunStrategy . ColdStart , RuntimeMoniker . Net60 ) ]
141+ [ SimpleJob ( RunStrategy . ColdStart , RuntimeMoniker . Net481 ) ]
142+ [ SimpleJob ( RunStrategy . ColdStart , RuntimeMoniker . NativeAot60 ) ]
143+ public class BenchmarkClass1
144+ {
145+ [ Benchmark ] public void Method ( ) { }
146+ }
86147 }
87148}
0 commit comments