Skip to content
Open
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
4 changes: 4 additions & 0 deletions Sources/RegexBenchmark/BenchmarkRegistration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ extension BenchmarkRunner {

self.addURLWithWordBoundaries()
self.addFSPathsRegex()

// Register community benchmarks
self.addCommunityBenchmark_sspringerURL()

// -- end of registrations --
}
}
28 changes: 28 additions & 0 deletions Sources/RegexBenchmark/Suite/URLRegex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,33 @@ extension BenchmarkRunner {
)
url.register(&self)
}

// Benchmark from forums user @sspringer
// https://github.com/stefanspringer1/SwiftRegexBenchmarks/tree/main
mutating func addCommunityBenchmark_sspringerURL() {
let urlRegex = #"https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)*\/?"#
let rawData = """
URLs:
http://www.google.com
https://www.google.com
http://google.com
https://google.com
http://www.google.com/
https://www.google.com/
http://google.com/
https://google.com/
http://www.google.com/index.html
https://www.google.com/index.html
http://google.com/index.html
https://google.com/index.html
"""
let data = String(repeating: rawData, count: 100)
let url = CrossBenchmark(
baseName: "Community_sspringerURL",
regex: urlRegex,
input: data
)
url.register(&self)
}
}