@@ -27,13 +27,17 @@ public class Speed : IColumn
2727 {
2828 public string GetValue ( Summary summary , BenchmarkCase benchmarkCase )
2929 {
30+ if ( summary is null || benchmarkCase is null || benchmarkCase . Parameters is null )
31+ {
32+ return "N/A" ;
33+ }
3034 var ourReport = summary . Reports . First ( x => x . BenchmarkCase . Equals ( benchmarkCase ) ) ;
3135 var fileName = ( string ) benchmarkCase . Parameters [ "FileName" ] ;
32- long length = new System . IO . FileInfo ( fileName ) . Length ;
33- if ( ourReport . ResultStatistics is null )
36+ if ( ourReport is null || ourReport . ResultStatistics is null )
3437 {
3538 return "N/A" ;
3639 }
40+ long length = new System . IO . FileInfo ( fileName ) . Length ;
3741 var mean = ourReport . ResultStatistics . Mean ;
3842 return $ "{ ( length / ourReport . ResultStatistics . Mean ) : #####.00} ";
3943 }
@@ -57,8 +61,8 @@ public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
5761 [ Config ( typeof ( Config ) ) ]
5862 public class RealDataBenchmark
5963 {
60-
61- private class Config : ManualConfig
64+ #pragma warning disable CA1812
65+ private sealed class Config : ManualConfig
6266 {
6367 public Config ( )
6468 {
@@ -67,6 +71,7 @@ public Config()
6771
6872 if ( RuntimeInformation . ProcessArchitecture == Architecture . Arm64 )
6973 {
74+ #pragma warning disable CA1303
7075 Console . WriteLine ( "ARM64 system detected." ) ;
7176 AddFilter ( new AnyCategoriesFilter ( [ "arm64" , "scalar" , "runtime" ] ) ) ;
7277
@@ -75,21 +80,25 @@ public Config()
7580 {
7681 if ( Vector512 . IsHardwareAccelerated && System . Runtime . Intrinsics . X86 . Avx512Vbmi . IsSupported )
7782 {
83+ #pragma warning disable CA1303
7884 Console . WriteLine ( "X64 system detected (Intel, AMD,...) with AVX-512 support." ) ;
7985 AddFilter ( new AnyCategoriesFilter ( [ "avx512" , "avx" , "sse" , "scalar" , "runtime" ] ) ) ;
8086 }
8187 else if ( Avx2 . IsSupported )
8288 {
89+ #pragma warning disable CA1303
8390 Console . WriteLine ( "X64 system detected (Intel, AMD,...) with AVX2 support." ) ;
8491 AddFilter ( new AnyCategoriesFilter ( [ "avx" , "sse" , "scalar" , "runtime" ] ) ) ;
8592 }
8693 else if ( Ssse3 . IsSupported )
8794 {
95+ #pragma warning disable CA1303
8896 Console . WriteLine ( "X64 system detected (Intel, AMD,...) with Sse4.2 support." ) ;
8997 AddFilter ( new AnyCategoriesFilter ( [ "sse" , "scalar" , "runtime" ] ) ) ;
9098 }
9199 else
92100 {
101+ #pragma warning disable CA1303
93102 Console . WriteLine ( "X64 system detected (Intel, AMD,...) without relevant SIMD support." ) ;
94103 AddFilter ( new AnyCategoriesFilter ( [ "scalar" , "runtime" ] ) ) ;
95104 }
@@ -131,13 +140,13 @@ public Config()
131140 @"data/turkish.utf8.txt" ,
132141 @"data/vietnamese.utf8.txt" ) ]
133142 public string ? FileName ;
134- public byte [ ] allLinesUtf8 = new byte [ 0 ] ;
143+ private byte [ ] allLinesUtf8 = Array . Empty < byte > ( ) ;
135144
136145
137146 public unsafe delegate byte * Utf8ValidationFunction ( byte * pUtf8 , int length ) ;
138147 public unsafe delegate byte * DotnetRuntimeUtf8ValidationFunction ( byte * pUtf8 , int length , out int utf16CodeUnitCountAdjustment , out int scalarCountAdjustment ) ;
139148
140- public void RunUtf8ValidationBenchmark ( byte [ ] data , Utf8ValidationFunction validationFunction )
149+ private void RunUtf8ValidationBenchmark ( byte [ ] data , Utf8ValidationFunction validationFunction )
141150 {
142151 unsafe
143152 {
@@ -152,7 +161,7 @@ public void RunUtf8ValidationBenchmark(byte[] data, Utf8ValidationFunction valid
152161 }
153162 }
154163
155- public void RunDotnetRuntimeUtf8ValidationBenchmark ( byte [ ] data , DotnetRuntimeUtf8ValidationFunction validationFunction )
164+ private void RunDotnetRuntimeUtf8ValidationBenchmark ( byte [ ] data , DotnetRuntimeUtf8ValidationFunction validationFunction )
156165 {
157166 unsafe
158167 {
@@ -229,18 +238,18 @@ public unsafe void SIMDUtf8ValidationRealDataArm64()
229238
230239 [ Benchmark ]
231240 [ BenchmarkCategory ( "avx" ) ]
232- public unsafe void SIMDUtf8ValidationRealDataAvx2 ( )
233- {
234- if ( allLinesUtf8 != null )
235- {
241+ public unsafe void SIMDUtf8ValidationRealDataAvx2 ( )
242+ {
243+ if ( allLinesUtf8 != null )
244+ {
236245 RunUtf8ValidationBenchmark ( allLinesUtf8 , ( byte * pInputBuffer , int inputLength ) =>
237246 {
238247 int dummyUtf16CodeUnitCountAdjustment , dummyScalarCountAdjustment ;
239248 // Call the method with additional out parameters within the lambda.
240249 // You must handle these additional out parameters inside the lambda, as they cannot be passed back through the delegate.
241250 return SimdUnicode . UTF8 . GetPointerToFirstInvalidByteAvx2 ( pInputBuffer , inputLength , out dummyUtf16CodeUnitCountAdjustment , out dummyScalarCountAdjustment ) ;
242251 } ) ;
243- }
252+ }
244253 }
245254
246255 [ Benchmark ]
0 commit comments