Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let availabilityDefinition = PackageDescription.SwiftSetting.unsafeFlags([
"-Xfrontend",
"-define-availability",
"-Xfrontend",
"SwiftStdlib 5.7:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
"SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0",
"-Xfrontend",
"-define-availability",
"-Xfrontend",
Expand Down
18 changes: 13 additions & 5 deletions Sources/RegexBenchmark/BenchmarkRunner.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Foundation
@_spi(RegexBenchmark) import _StringProcessing

/// The number of times to re-run the benchmark if results are too varying
private var rerunCount: Int { 3 }

struct BenchmarkRunner {
let suiteName: String
var suite: [any RegexBenchmark] = []
Expand Down Expand Up @@ -82,11 +85,16 @@ struct BenchmarkRunner {
for b in suite {
var result = measure(benchmark: b, samples: samples)
if result.runtimeIsTooVariant {
print("Warning: Standard deviation > \(Stats.maxAllowedStdev*100)% for \(b.name)")
print(result.runtime)
print("Rerunning \(b.name)")
result = measure(benchmark: b, samples: result.runtime.samples*2)
print(result.runtime)
for _ in 0..<rerunCount {
print("Warning: Standard deviation > \(Stats.maxAllowedStdev*100)% for \(b.name)")
print(result.runtime)
print("Rerunning \(b.name)")
result = measure(benchmark: b, samples: result.runtime.samples*2)
print(result.runtime)
if !result.runtimeIsTooVariant {
break
}
}
if result.runtimeIsTooVariant {
fatalError("Benchmark \(b.name) is too variant")
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/_StringProcessing/Engine/MEBuiltins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ extension Processor {
return nil
}

let asciiCheck = (char.isASCII && !isScalarSemantics)
let asciiCheck = !isStrictASCII
|| (scalar.isASCII && isScalarSemantics)
|| !isStrictASCII
|| char.isASCII

var matched: Bool
var next: Input.Index
Expand Down
5 changes: 3 additions & 2 deletions Sources/_StringProcessing/_CharacterClassModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ struct _CharacterClassModel: Hashable {
let char = input[currentPosition]
let scalar = input.unicodeScalars[currentPosition]
let isScalarSemantics = matchLevel == .unicodeScalar
let asciiCheck = (char.isASCII && !isScalarSemantics)

let asciiCheck = !isStrictASCII
|| (scalar.isASCII && isScalarSemantics)
|| !isStrictASCII
|| char.isASCII

var matched: Bool
var next: String.Index
Expand Down