@@ -27,13 +27,17 @@ public class Speed : IColumn
27
27
{
28
28
public string GetValue ( Summary summary , BenchmarkCase benchmarkCase )
29
29
{
30
+ if ( summary is null || benchmarkCase is null || benchmarkCase . Parameters is null )
31
+ {
32
+ return "N/A" ;
33
+ }
30
34
var ourReport = summary . Reports . First ( x => x . BenchmarkCase . Equals ( benchmarkCase ) ) ;
31
35
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 )
34
37
{
35
38
return "N/A" ;
36
39
}
40
+ long length = new System . IO . FileInfo ( fileName ) . Length ;
37
41
var mean = ourReport . ResultStatistics . Mean ;
38
42
return $ "{ ( length / ourReport . ResultStatistics . Mean ) : #####.00} ";
39
43
}
@@ -57,8 +61,8 @@ public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
57
61
[ Config ( typeof ( Config ) ) ]
58
62
public class RealDataBenchmark
59
63
{
60
-
61
- private class Config : ManualConfig
64
+ #pragma warning disable CA1812
65
+ private sealed class Config : ManualConfig
62
66
{
63
67
public Config ( )
64
68
{
@@ -67,6 +71,7 @@ public Config()
67
71
68
72
if ( RuntimeInformation . ProcessArchitecture == Architecture . Arm64 )
69
73
{
74
+ #pragma warning disable CA1303
70
75
Console . WriteLine ( "ARM64 system detected." ) ;
71
76
AddFilter ( new AnyCategoriesFilter ( [ "arm64" , "scalar" , "runtime" ] ) ) ;
72
77
@@ -75,21 +80,25 @@ public Config()
75
80
{
76
81
if ( Vector512 . IsHardwareAccelerated && System . Runtime . Intrinsics . X86 . Avx512Vbmi . IsSupported )
77
82
{
83
+ #pragma warning disable CA1303
78
84
Console . WriteLine ( "X64 system detected (Intel, AMD,...) with AVX-512 support." ) ;
79
85
AddFilter ( new AnyCategoriesFilter ( [ "avx512" , "avx" , "sse" , "scalar" , "runtime" ] ) ) ;
80
86
}
81
87
else if ( Avx2 . IsSupported )
82
88
{
89
+ #pragma warning disable CA1303
83
90
Console . WriteLine ( "X64 system detected (Intel, AMD,...) with AVX2 support." ) ;
84
91
AddFilter ( new AnyCategoriesFilter ( [ "avx" , "sse" , "scalar" , "runtime" ] ) ) ;
85
92
}
86
93
else if ( Ssse3 . IsSupported )
87
94
{
95
+ #pragma warning disable CA1303
88
96
Console . WriteLine ( "X64 system detected (Intel, AMD,...) with Sse4.2 support." ) ;
89
97
AddFilter ( new AnyCategoriesFilter ( [ "sse" , "scalar" , "runtime" ] ) ) ;
90
98
}
91
99
else
92
100
{
101
+ #pragma warning disable CA1303
93
102
Console . WriteLine ( "X64 system detected (Intel, AMD,...) without relevant SIMD support." ) ;
94
103
AddFilter ( new AnyCategoriesFilter ( [ "scalar" , "runtime" ] ) ) ;
95
104
}
@@ -131,13 +140,13 @@ public Config()
131
140
@"data/turkish.utf8.txt" ,
132
141
@"data/vietnamese.utf8.txt" ) ]
133
142
public string ? FileName ;
134
- public byte [ ] allLinesUtf8 = new byte [ 0 ] ;
143
+ private byte [ ] allLinesUtf8 = Array . Empty < byte > ( ) ;
135
144
136
145
137
146
public unsafe delegate byte * Utf8ValidationFunction ( byte * pUtf8 , int length ) ;
138
147
public unsafe delegate byte * DotnetRuntimeUtf8ValidationFunction ( byte * pUtf8 , int length , out int utf16CodeUnitCountAdjustment , out int scalarCountAdjustment ) ;
139
148
140
- public void RunUtf8ValidationBenchmark ( byte [ ] data , Utf8ValidationFunction validationFunction )
149
+ private void RunUtf8ValidationBenchmark ( byte [ ] data , Utf8ValidationFunction validationFunction )
141
150
{
142
151
unsafe
143
152
{
@@ -152,7 +161,7 @@ public void RunUtf8ValidationBenchmark(byte[] data, Utf8ValidationFunction valid
152
161
}
153
162
}
154
163
155
- public void RunDotnetRuntimeUtf8ValidationBenchmark ( byte [ ] data , DotnetRuntimeUtf8ValidationFunction validationFunction )
164
+ private void RunDotnetRuntimeUtf8ValidationBenchmark ( byte [ ] data , DotnetRuntimeUtf8ValidationFunction validationFunction )
156
165
{
157
166
unsafe
158
167
{
@@ -229,18 +238,18 @@ public unsafe void SIMDUtf8ValidationRealDataArm64()
229
238
230
239
[ Benchmark ]
231
240
[ BenchmarkCategory ( "avx" ) ]
232
- public unsafe void SIMDUtf8ValidationRealDataAvx2 ( )
233
- {
234
- if ( allLinesUtf8 != null )
235
- {
241
+ public unsafe void SIMDUtf8ValidationRealDataAvx2 ( )
242
+ {
243
+ if ( allLinesUtf8 != null )
244
+ {
236
245
RunUtf8ValidationBenchmark ( allLinesUtf8 , ( byte * pInputBuffer , int inputLength ) =>
237
246
{
238
247
int dummyUtf16CodeUnitCountAdjustment , dummyScalarCountAdjustment ;
239
248
// Call the method with additional out parameters within the lambda.
240
249
// You must handle these additional out parameters inside the lambda, as they cannot be passed back through the delegate.
241
250
return SimdUnicode . UTF8 . GetPointerToFirstInvalidByteAvx2 ( pInputBuffer , inputLength , out dummyUtf16CodeUnitCountAdjustment , out dummyScalarCountAdjustment ) ;
242
251
} ) ;
243
- }
252
+ }
244
253
}
245
254
246
255
[ Benchmark ]
0 commit comments