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 1
1
import Foundation
2
2
@_spi ( RegexBenchmark) import _StringProcessing
3
3
4
+ /// The number of times to re-run the benchmark if results are too varying
5
+ private var rerunCount : Int { 3 }
6
+
4
7
struct BenchmarkRunner {
5
8
let suiteName : String
6
9
var suite : [ any RegexBenchmark ] = [ ]
@@ -82,11 +85,16 @@ struct BenchmarkRunner {
82
85
for b in suite {
83
86
var result = measure ( benchmark: b, samples: samples)
84
87
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
+ }
90
98
if result. runtimeIsTooVariant {
91
99
fatalError ( " Benchmark \( b. name) is too variant " )
92
100
}
Original file line number Diff line number Diff line change @@ -38,9 +38,9 @@ extension Processor {
38
38
return nil
39
39
}
40
40
41
- let asciiCheck = ( char . isASCII && !isScalarSemantics )
41
+ let asciiCheck = !isStrictASCII
42
42
|| ( scalar. isASCII && isScalarSemantics)
43
- || !isStrictASCII
43
+ || char . isASCII
44
44
45
45
var matched : Bool
46
46
var next : Input . Index
Original file line number Diff line number Diff line change @@ -81,9 +81,10 @@ struct _CharacterClassModel: Hashable {
81
81
let char = input [ currentPosition]
82
82
let scalar = input. unicodeScalars [ currentPosition]
83
83
let isScalarSemantics = matchLevel == . unicodeScalar
84
- let asciiCheck = ( char. isASCII && !isScalarSemantics)
84
+
85
+ let asciiCheck = !isStrictASCII
85
86
|| ( scalar. isASCII && isScalarSemantics)
86
- || !isStrictASCII
87
+ || char . isASCII
87
88
88
89
var matched : Bool
89
90
var next : String . Index
You can’t perform that action at this time.
0 commit comments