Skip to content

Commit 71f8d49

Browse files
authored
Add benchmark from sspringer (#783)
1 parent e717079 commit 71f8d49

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Sources/RegexBenchmark/BenchmarkRegistration.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ extension BenchmarkRunner {
3232

3333
self.addURLWithWordBoundaries()
3434
self.addFSPathsRegex()
35+
36+
// Register community benchmarks
37+
self.addCommunityBenchmark_sspringerURL()
38+
3539
// -- end of registrations --
3640
}
3741
}

Sources/RegexBenchmark/Suite/URLRegex.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,33 @@ extension BenchmarkRunner {
2222
)
2323
url.register(&self)
2424
}
25+
26+
// Benchmark from forums user @sspringer
27+
// https://github.com/stefanspringer1/SwiftRegexBenchmarks/tree/main
28+
mutating func addCommunityBenchmark_sspringerURL() {
29+
let urlRegex = #"https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)*\/?"#
30+
let rawData = """
31+
URLs:
32+
http://www.google.com
33+
https://www.google.com
34+
http://google.com
35+
https://google.com
36+
http://www.google.com/
37+
https://www.google.com/
38+
http://google.com/
39+
https://google.com/
40+
http://www.google.com/index.html
41+
https://www.google.com/index.html
42+
http://google.com/index.html
43+
https://google.com/index.html
44+
"""
45+
let data = String(repeating: rawData, count: 100)
46+
let url = CrossBenchmark(
47+
baseName: "Community_sspringerURL",
48+
regex: urlRegex,
49+
input: data
50+
)
51+
url.register(&self)
52+
}
2553
}
2654

0 commit comments

Comments
 (0)