File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 11import Foundation
22@_spi ( RegexBenchmark) import _StringProcessing
33
4+ /// The number of times to re-run the benchmark if results are too varying
5+ private var rerunCount : Int { 3 }
6+
47struct BenchmarkRunner {
58 let suiteName : String
69 var suite : [ any RegexBenchmark ] = [ ]
@@ -82,11 +85,16 @@ struct BenchmarkRunner {
8285 for b in suite {
8386 var result = measure ( benchmark: b, samples: samples)
8487 if result. runtimeIsTooVariant {
85- print ( " Warning: Standard deviation > \( Stats . maxAllowedStdev*100) % for \( b. name) " )
86- print ( result. runtime)
87- print ( " Rerunning \( b. name) " )
88- result = measure ( benchmark: b, samples: result. runtime. samples*2)
89- print ( result. runtime)
88+ for _ in 0 ..< rerunCount {
89+ print ( " Warning: Standard deviation > \( Stats . maxAllowedStdev*100) % for \( b. name) " )
90+ print ( result. runtime)
91+ print ( " Rerunning \( b. name) " )
92+ result = measure ( benchmark: b, samples: result. runtime. samples*2)
93+ print ( result. runtime)
94+ if !result. runtimeIsTooVariant {
95+ break
96+ }
97+ }
9098 if result. runtimeIsTooVariant {
9199 fatalError ( " Benchmark \( b. name) is too variant " )
92100 }
Original file line number Diff line number Diff line change @@ -38,9 +38,9 @@ extension Processor {
3838 return nil
3939 }
4040
41- let asciiCheck = ( char . isASCII && !isScalarSemantics )
41+ let asciiCheck = !isStrictASCII
4242 || ( scalar. isASCII && isScalarSemantics)
43- || !isStrictASCII
43+ || char . isASCII
4444
4545 var matched : Bool
4646 var next : Input . Index
Original file line number Diff line number Diff line change @@ -81,9 +81,10 @@ struct _CharacterClassModel: Hashable {
8181 let char = input [ currentPosition]
8282 let scalar = input. unicodeScalars [ currentPosition]
8383 let isScalarSemantics = matchLevel == . unicodeScalar
84- let asciiCheck = ( char. isASCII && !isScalarSemantics)
84+
85+ let asciiCheck = !isStrictASCII
8586 || ( scalar. isASCII && isScalarSemantics)
86- || !isStrictASCII
87+ || char . isASCII
8788
8889 var matched : Bool
8990 var next : String . Index
You can’t perform that action at this time.
0 commit comments