10
10
using System . Security . Cryptography ;
11
11
12
12
using BenchmarkDotNet . Attributes ;
13
+ using BenchmarkDotNet . Configs ;
14
+ using BenchmarkDotNet . Jobs ;
15
+ using BenchmarkDotNet . Toolchains . CsProj ;
16
+ using BenchmarkDotNet . Toolchains . DotNetCli ;
13
17
using BenchmarkDotNet . Running ;
14
18
15
19
namespace System . Text . CaseFolding
@@ -18,12 +22,46 @@ public class Program
18
22
{
19
23
public static void Main ( string [ ] args )
20
24
{
21
- var summary = BenchmarkRunner . Run < StringFoldingBenchmark > ( ) ;
25
+ var summary = BenchmarkRunner . Run < StringFoldingBenchmark_SimpleCaseFold > ( ) ;
22
26
Console . WriteLine ( "Result: {0}" , SimpleCaseFolding . SimpleCaseFold ( "cASEfOLDING2" ) ) ;
23
27
Console . WriteLine ( "Result: {0}" , SimpleCaseFolding . SimpleCaseFold ( "яЯяЯяЯяЯяЯя2" ) ) ;
24
28
}
25
29
}
26
30
31
+ [ DisassemblyDiagnoser ( printAsm : true , printSource : true , recursiveDepth : 2 ) ]
32
+ [ Config ( typeof ( ConfigWithCustomEnvVars ) ) ]
33
+ public class StringFoldingBenchmark_SimpleCaseFold
34
+ {
35
+ private class ConfigWithCustomEnvVars : ManualConfig
36
+ {
37
+ private const string JitNoInline = "COMPlus_TieredCompilation" ;
38
+
39
+ public ConfigWithCustomEnvVars ( )
40
+ {
41
+ Add ( Job . Core
42
+ . With ( new [ ] { new EnvironmentVariable ( JitNoInline , "1" ) } )
43
+ . WithTargetCount ( 20 )
44
+ . WithUnrollFactor ( 20 )
45
+ . With ( CsProjCoreToolchain . From ( NetCoreAppSettings . NetCoreApp30 ) ) ) ;
46
+ }
47
+ }
48
+
49
+ [ Params ( 'A' , '\u0600 ' ) ]
50
+ public char TestChar { get ; set ; }
51
+
52
+ [ Benchmark ( Baseline = true ) ]
53
+ public char SimpleCaseFold ( )
54
+ {
55
+ return SimpleCaseFolding . SimpleCaseFold ( TestChar ) ;
56
+ }
57
+
58
+ [ Benchmark ]
59
+ public char SimpleCaseFoldTest ( )
60
+ {
61
+ return SimpleCaseFolding . SimpleCaseFoldTest ( TestChar ) ;
62
+ }
63
+ }
64
+
27
65
[ DisassemblyDiagnoser ( printAsm : true , printSource : true , recursiveDepth : 3 ) ]
28
66
public class StringFoldingBenchmark
29
67
{
0 commit comments