Skip to content

Commit 5359e31

Browse files
committed
Revert "Merge branch 'just-one-more-benchmark-suite' into temp"
This reverts commit df8919e, reversing changes made to 3a2b324.
1 parent b4c7c8c commit 5359e31

17 files changed

+34
-18917
lines changed

Sources/RegexBenchmark/Benchmark.swift

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,11 @@ struct CrossBenchmark {
6969
/// TODO: Probably better ot have a whole-line vs search anywhere, maybe
7070
/// accomodate multi-line matching, etc.
7171
var isWhole: Bool = false
72-
73-
/// Whether or not to do firstMatch as well or just allMatches
74-
var includeFirst: Bool = false
7572

7673
func register(_ runner: inout BenchmarkRunner) {
7774
let swiftRegex = try! Regex(regex)
75+
76+
let nsPattern = isWhole ? "^" + regex + "$" : regex
7877
let nsRegex: NSRegularExpression
7978
if isWhole {
8079
nsRegex = try! NSRegularExpression(pattern: "^" + regex + "$")
@@ -96,32 +95,30 @@ struct CrossBenchmark {
9695
type: .first,
9796
target: input))
9897
} else {
98+
runner.register(
99+
Benchmark(
100+
name: baseName + "First",
101+
regex: swiftRegex,
102+
type: .first,
103+
target: input))
99104
runner.register(
100105
Benchmark(
101106
name: baseName + "All",
102107
regex: swiftRegex,
103108
type: .allMatches,
104109
target: input))
110+
runner.register(
111+
NSBenchmark(
112+
name: baseName + "First_NS",
113+
regex: nsRegex,
114+
type: .first,
115+
target: input))
105116
runner.register(
106117
NSBenchmark(
107118
name: baseName + "All_NS",
108119
regex: nsRegex,
109120
type: .allMatches,
110121
target: input))
111-
if includeFirst {
112-
runner.register(
113-
Benchmark(
114-
name: baseName + "First",
115-
regex: swiftRegex,
116-
type: .first,
117-
target: input))
118-
runner.register(
119-
NSBenchmark(
120-
name: baseName + "First_NS",
121-
regex: nsRegex,
122-
type: .first,
123-
target: input))
124-
}
125122
}
126123
}
127124
}

Sources/RegexBenchmark/BenchmarkRegistration.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ extension BenchmarkRunner {
1616
benchmark.addHTML()
1717
benchmark.addEmail()
1818
benchmark.addCustomCharacterClasses()
19-
benchmark.addDna()
20-
benchmark.addUnicode()
21-
benchmark.addLiteralSearch()
2219
// -- end of registrations --
2320
return benchmark
2421
}

Sources/RegexBenchmark/CLI.swift

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ArgumentParser
22

33
@main
44
struct Runner: ParsableCommand {
5-
@Argument(help: "Patterns for benchmarks to run")
5+
@Argument(help: "Names of benchmarks to run")
66
var specificBenchmarks: [String] = []
77

88
@Flag(help: "Run only once for profiling purposes")
@@ -20,30 +20,19 @@ struct Runner: ParsableCommand {
2020
@Flag(help: "Should the results be saved")
2121
var save = false
2222

23-
@Flag(help: "Compare this result with a saved result")
23+
@Flag(help: "Compare this result with the latest saved result")
2424
var compare = false
2525

2626
@Option(help: "The result file to compare against, if this flag is not set it will compare against the most recent result file")
2727
var compareFile: String?
2828

29-
@Flag(help: "Exclude the comparisons to NSRegex")
30-
var excludeNs = false
31-
3229
mutating func run() throws {
3330
var runner = BenchmarkRunner.makeRunner(samples, outputPath)
34-
35-
if !self.specificBenchmarks.isEmpty {
36-
runner.suite = runner.suite.filter { b in
37-
specificBenchmarks.contains { pattern in
38-
try! Regex(pattern).wholeMatch(in: b.name) != nil
39-
}
40-
}
41-
}
4231

43-
if excludeNs {
44-
runner.suite = runner.suite.filter { b in !b.name.contains("NS") }
32+
// todo: regex based filter
33+
if !self.specificBenchmarks.isEmpty {
34+
runner.suite = runner.suite.filter { b in specificBenchmarks.contains(b.name) }
4535
}
46-
4736
switch (profile, debug) {
4837
case (true, true): print("Cannot run both profile and debug")
4938
case (true, false): runner.profile()

Sources/RegexBenchmark/Inputs/DnaFASTA.swift

Lines changed: 0 additions & 16676 deletions
This file was deleted.

Sources/RegexBenchmark/Inputs/TaggedUnicode.swift

Lines changed: 0 additions & 2008 deletions
This file was deleted.

Sources/RegexBenchmark/Suite/CssRegex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extension BenchmarkRunner {
66
let r = #"--([a-zA-Z0-9_-]+)\s*:\s*(.*?);"#
77

88
let css = CrossBenchmark(
9-
baseName: "Css", regex: r, input: Inputs.swiftOrgCSS)
9+
baseName: "css", regex: r, input: Inputs.swiftOrgCSS)
1010
css.register(&self)
1111
}
1212
}

Sources/RegexBenchmark/Suite/CustomCharacterClasses.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,37 @@ extension BenchmarkRunner {
1313
let input = Inputs.graphemeBreakData
1414

1515
register(Benchmark(
16-
name: "BasicCCC",
16+
name: "basicCCC",
1717
regex: try! Regex(basic),
1818
type: .allMatches,
1919
target: input))
2020

2121
register(Benchmark(
22-
name: "BasicRangeCCC",
22+
name: "basicRangeCCC",
2323
regex: try! Regex(basicRange),
2424
type: .allMatches,
2525
target: input))
2626

2727
register(Benchmark(
28-
name: "CaseInsensitiveCCC",
28+
name: "caseInsensitiveCCC",
2929
regex: try! Regex(caseInsensitive),
3030
type: .allMatches,
3131
target: input))
3232

3333
register(Benchmark(
34-
name: "InvertedCCC",
34+
name: "invertedCCC",
3535
regex: try! Regex(inverted),
3636
type: .allMatches,
3737
target: input))
3838

3939
register(Benchmark(
40-
name: "SubtractionCCC",
40+
name: "subtractionCCC",
4141
regex: try! Regex(subtraction),
4242
type: .allMatches,
4343
target: input))
4444

4545
register(Benchmark(
46-
name: "IntersectionCCC",
46+
name: "intersectionCCC",
4747
regex: try! Regex(intersection),
4848
type: .allMatches,
4949
target: input))

Sources/RegexBenchmark/Suite/Dna.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

Sources/RegexBenchmark/Suite/EmailRegex.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ extension BenchmarkRunner {
1313
let emailWithLookaheads = #"(?=[A-z0-9][A-z0-9@._%+-]{5,253})[A-z0-9._%+-]{1,64}@(?:(?=[A-z0-9-]{1,63}\.)[A-z0-9]+(?:-[A-z0-9]+)*\.){1,8}[A-z]{2,63}"#
1414

1515
let emailRFCValid = CrossBenchmark(
16-
baseName: "EmailRFC", regex: emailRFC, input: Inputs.validEmails)
16+
baseName: "emailRFC", regex: emailRFC, input: Inputs.validEmails)
1717

1818
let emailRFCInvalid = CrossBenchmark(
19-
baseName: "EmailRFCNoMatches",
19+
baseName: "emailRFCNoMatches",
2020
regex: emailRFC,
2121
input: Inputs.graphemeBreakData
2222
)
2323

2424
let emailValid = CrossBenchmark(
25-
baseName: "EmailLookahead",
25+
baseName: "emailLookahead",
2626
regex: emailWithLookaheads,
2727
input: Inputs.validEmails
2828
)
2929

3030
let emailInvalid = CrossBenchmark(
31-
baseName: "EmailLookaheadNoMatches",
31+
baseName: "emailLookaheadNoMatches",
3232
regex: emailWithLookaheads,
3333
input: Inputs.graphemeBreakData
3434
)

Sources/RegexBenchmark/Suite/GraphemeBreak.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension BenchmarkRunner {
1818
let regex = #"HANGUL SYLLABLE [A-Z]+(?:\.\.HANGUL SYLLABLE [A-Z]+)?"#
1919

2020
let benchmark = CrossBenchmark(
21-
baseName: "HangulSyllable", regex: regex, input: input, includeFirst: true)
21+
baseName: "HangulSyllable", regex: regex, input: input)
2222
benchmark.register(&self)
2323
}
2424
}

0 commit comments

Comments
 (0)