File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ extension SwiftRegexBenchmark {
33
33
let _ = regex. _forceAction ( . addOptions( . enableTracing) )
34
34
}
35
35
mutating func enableMetrics( ) {
36
- let _ = regex. _forceAction ( . addOptions( [ . enableMetrics, . disableOptimizations ] ) )
36
+ let _ = regex. _forceAction ( . addOptions( [ . enableMetrics] ) )
37
37
}
38
38
}
39
39
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ struct BenchmarkRunner {
59
59
var benchmark = benchmark as! SwiftRegexBenchmark
60
60
compileTime = medianMeasure ( samples: samples) { benchmark. compile ( ) }
61
61
// Can't parse if we don't have an input string (ie a builder regex)
62
- if benchmark. parse ( ) {
62
+ if benchmark. pattern != nil {
63
63
parseTime = medianMeasure ( samples: samples) { let _ = benchmark. parse ( ) }
64
64
} else {
65
65
parseTime = nil
@@ -81,13 +81,13 @@ struct BenchmarkRunner {
81
81
print ( " Running " )
82
82
for b in suite {
83
83
var result = measure ( benchmark: b, samples: samples)
84
- if result. runtime . stdev > Stats . maxAllowedStdev * result . runtime . median . seconds {
84
+ if result. runtimeIsTooVariant {
85
85
print ( " Warning: Standard deviation > \( Stats . maxAllowedStdev*100) % for \( b. name) " )
86
86
print ( result. runtime)
87
87
print ( " Rerunning \( b. name) " )
88
88
result = measure ( benchmark: b, samples: result. runtime. samples*2)
89
89
print ( result. runtime)
90
- if result. runtime . stdev > Stats . maxAllowedStdev {
90
+ if result. runtimeIsTooVariant {
91
91
fatalError ( " Benchmark \( b. name) is too variant " )
92
92
}
93
93
}
Original file line number Diff line number Diff line change @@ -18,3 +18,9 @@ extension Stats {
18
18
return abs ( tVal) > 2
19
19
}
20
20
}
21
+
22
+ extension BenchmarkResult {
23
+ var runtimeIsTooVariant : Bool {
24
+ runtime. stdev > Stats . maxAllowedStdev * runtime. median. seconds
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments