File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
src/benchmarks/micro/libraries Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ public IEnumerable<object> SByteValues
8585 public bool TryParseSByte ( Utf8TestCase value ) => Utf8Parser . TryParse ( value . Utf8Bytes , out sbyte _ , out int _ ) ;
8686
8787 public IEnumerable < object > BooleanValues
88- => Perf_Boolean . StringValues . OfType < string > ( ) . Select ( formatted => new Utf8TestCase ( formatted ) ) ;
88+ => Perf_Boolean . ValidStringValues . OfType < string > ( ) . Select ( formatted => new Utf8TestCase ( formatted ) ) ;
8989
9090 [ Benchmark ]
9191 [ ArgumentsSource ( nameof ( BooleanValues ) ) ]
Original file line number Diff line number Diff line change @@ -12,20 +12,30 @@ namespace System.Tests
1212 [ BenchmarkCategory ( Categories . Libraries ) ]
1313 public class Perf_Boolean
1414 {
15- public static IEnumerable < object > StringValues => Values . Select ( value => value . ToString ( ) ) . ToArray ( ) ;
16-
15+ public static IEnumerable < object > ValidStringValues => new string [ ] {
16+ "true" ,
17+ "false" ,
18+ "TRUE" ,
19+ "False" ,
20+ " True "
21+ } ;
22+ public static IEnumerable < object > ValidAndInvalidStringValues => ValidStringValues . Concat ( new string [ ]
23+ {
24+ "0" ,
25+ "Bogus"
26+ } ) ;
1727 public static IEnumerable < object > Values => new object [ ]
1828 {
1929 true ,
2030 false
2131 } ;
2232
2333 [ Benchmark ]
24- [ ArgumentsSource ( nameof ( StringValues ) ) ]
34+ [ ArgumentsSource ( nameof ( ValidStringValues ) ) ]
2535 public bool Parse ( string value ) => bool . Parse ( value ) ;
2636
2737 [ Benchmark ]
28- [ ArgumentsSource ( nameof ( StringValues ) ) ]
38+ [ ArgumentsSource ( nameof ( ValidAndInvalidStringValues ) ) ]
2939 public bool TryParse ( string value ) => bool . TryParse ( value , out _ ) ;
3040
3141 [ Benchmark ]
You can’t perform that action at this time.
0 commit comments