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
40 changes: 21 additions & 19 deletions Benchmarks/Benchmarks/URL/BenchmarkURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,38 @@ let benchmarks = {

// MARK: - String Parsing

Benchmark("URL-ParseValidASCII") { benchmark in
Benchmark("URL.ParseValidASCII") { benchmark in
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the benchmark names to use . so they display better in the JMH visualizer.

for _ in benchmark.scaledIterations {
blackHole(URL(string: validURLString))
}
}

Benchmark("URLComponents-ParseValidASCII") { benchmark in
Benchmark("URLComponents.ParseValidASCII") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(URLComponents(string: validURLString))
}
}

Benchmark("URL-ParseInvalid") { benchmark in
Benchmark("URL.ParseInvalid") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(URL(string: invalidURLString))
}
}

Benchmark("URLComponents-ParseInvalid") { benchmark in
Benchmark("URLComponents.ParseInvalid") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(URLComponents(string: invalidURLString))
}
}

#if os(macOS) || compiler(>=6)
Benchmark("URL-ParseAndEncode") { benchmark in
Benchmark("URL.ParseAndEncode") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(URL(string: encodableURLString))
}
}

Benchmark("URLComponents-ParseAndEncode") { benchmark in
Benchmark("URLComponents.ParseAndEncode") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(URLComponents(string: encodableURLString))
}
Expand All @@ -87,7 +87,7 @@ let benchmarks = {

#if os(macOS) || compiler(>=6)
// Component functions, e.g. path(), are available in macOS 13 and Swift 6
Benchmark("URL-GetEncodedComponents") { benchmark in
Benchmark("URL.GetEncodedComponents") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(encodedURL.scheme)
blackHole(encodedURL.user())
Expand All @@ -100,7 +100,7 @@ let benchmarks = {
}
#endif

Benchmark("URLComponents-GetEncodedComponents") { benchmark in
Benchmark("URLComponents.GetEncodedComponents") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(encodedComp.scheme)
blackHole(encodedComp.percentEncodedUser)
Expand All @@ -116,7 +116,7 @@ let benchmarks = {
}
}

Benchmark("URL-GetDecodedComponents") { benchmark in
Benchmark("URL.GetDecodedComponents") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(encodedURL.scheme)
blackHole(encodedURL.user)
Expand All @@ -128,7 +128,7 @@ let benchmarks = {
}
}

Benchmark("URLComponents-GetDecodedComponents") { benchmark in
Benchmark("URLComponents.GetDecodedComponents") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(encodedComp.scheme)
blackHole(encodedComp.user)
Expand All @@ -141,7 +141,7 @@ let benchmarks = {
}

let validComp = URLComponents(string: validURLString)!
Benchmark("URLComponents-GetComponentRanges") { benchmark in
Benchmark("URLComponents.GetComponentRanges") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(validComp.rangeOfScheme)
blackHole(validComp.rangeOfUser)
Expand All @@ -156,7 +156,7 @@ let benchmarks = {

// MARK: - Set URL Components

Benchmark("URLComponents-SetComponents") { benchmark in
Benchmark("URLComponents.SetComponents") { benchmark in
for _ in benchmark.scaledIterations {
var comp = URLComponents()
comp.scheme = "scheme"
Expand All @@ -171,7 +171,7 @@ let benchmarks = {
}
}

Benchmark("URLComponents-SetEncodableComponents") { benchmark in
Benchmark("URLComponents.SetEncodableComponents") { benchmark in
for _ in benchmark.scaledIterations {
var comp = URLComponents()
comp.scheme = "scheme"
Expand Down Expand Up @@ -200,15 +200,15 @@ let benchmarks = {
URLQueryItem(name: "name with no value", value: nil)
]

Benchmark("URLComponents-SetQueryItems") { benchmark in
Benchmark("URLComponents.SetQueryItems") { benchmark in
for _ in benchmark.scaledIterations {
var comp = URLComponents()
comp.queryItems = validQueryItems
blackHole(comp)
}
}

Benchmark("URLComponents-SetEncodableQueryItems") { benchmark in
Benchmark("URLComponents.SetEncodableQueryItems") { benchmark in
for _ in benchmark.scaledIterations {
var comp = URLComponents()
comp.queryItems = encodableQueryItems
Expand All @@ -219,19 +219,21 @@ let benchmarks = {
var queryComp = URLComponents()
queryComp.queryItems = encodableQueryItems

Benchmark("URLComponents-GetEncodedQueryItems") { benchmark in
Benchmark("URLComponents.GetEncodedQueryItems") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(queryComp.percentEncodedQueryItems)
}
}

Benchmark("URLComponents-GetDecodedQueryItems") { benchmark in
Benchmark("URLComponents.GetDecodedQueryItems") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(queryComp.queryItems)
}
}

Benchmark("URL-Template-parsing") { benchmark in
// MARK: - URL.Template

Benchmark("URL.TemplateParsing") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(URL.Template("/api/{version}/accounts/{accountId}/transactions/{transactionId}{?expand*,fields*,embed*,format}")!)
blackHole(URL.Template("/special/{+a}/details")!)
Expand Down Expand Up @@ -270,7 +272,7 @@ let benchmarks = {
.init("empty_keys"): [:],
]

Benchmark("URL-Template-expansion") { benchmark in
Benchmark("URL.TemplateExpansion") { benchmark in
for _ in benchmark.scaledIterations {
for t in templates {
blackHole(URL(template: t, variables: variables))
Expand Down
Loading