diff --git a/Sources/RegexBenchmark/BenchmarkRegistration.swift b/Sources/RegexBenchmark/BenchmarkRegistration.swift index a812b84b..41f3e5ed 100644 --- a/Sources/RegexBenchmark/BenchmarkRegistration.swift +++ b/Sources/RegexBenchmark/BenchmarkRegistration.swift @@ -21,6 +21,10 @@ extension BenchmarkRunner { self.addURLWithWordBoundaries() self.addFSPathsRegex() + + // Register community benchmarks + self.addCommunityBenchmark_sspringerURL() + // -- end of registrations -- } } diff --git a/Sources/RegexBenchmark/Suite/URLRegex.swift b/Sources/RegexBenchmark/Suite/URLRegex.swift index 9e28f539..4accd69c 100644 --- a/Sources/RegexBenchmark/Suite/URLRegex.swift +++ b/Sources/RegexBenchmark/Suite/URLRegex.swift @@ -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) + } }