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 {
3333 let _ = regex. _forceAction ( . addOptions( . enableTracing) )
3434 }
3535 mutating func enableMetrics( ) {
36- let _ = regex. _forceAction ( . addOptions( [ . enableMetrics, . disableOptimizations ] ) )
36+ let _ = regex. _forceAction ( . addOptions( [ . enableMetrics] ) )
3737 }
3838}
3939
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ struct BenchmarkRunner {
5959 var benchmark = benchmark as! SwiftRegexBenchmark
6060 compileTime = medianMeasure ( samples: samples) { benchmark. compile ( ) }
6161 // Can't parse if we don't have an input string (ie a builder regex)
62- if benchmark. parse ( ) {
62+ if benchmark. pattern != nil {
6363 parseTime = medianMeasure ( samples: samples) { let _ = benchmark. parse ( ) }
6464 } else {
6565 parseTime = nil
@@ -81,13 +81,13 @@ struct BenchmarkRunner {
8181 print ( " Running " )
8282 for b in suite {
8383 var result = measure ( benchmark: b, samples: samples)
84- if result. runtime . stdev > Stats . maxAllowedStdev * result . runtime . median . seconds {
84+ if result. runtimeIsTooVariant {
8585 print ( " Warning: Standard deviation > \( Stats . maxAllowedStdev*100) % for \( b. name) " )
8686 print ( result. runtime)
8787 print ( " Rerunning \( b. name) " )
8888 result = measure ( benchmark: b, samples: result. runtime. samples*2)
8989 print ( result. runtime)
90- if result. runtime . stdev > Stats . maxAllowedStdev {
90+ if result. runtimeIsTooVariant {
9191 fatalError ( " Benchmark \( b. name) is too variant " )
9292 }
9393 }
Original file line number Diff line number Diff line change @@ -18,3 +18,9 @@ extension Stats {
1818 return abs ( tVal) > 2
1919 }
2020}
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