Skip to content

Switch to benchmark remove* instead of drop* #32551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2020
Merged
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
24 changes: 13 additions & 11 deletions benchmark/single-source/Substring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public let SubstringTest = [
BenchmarkInfo(name: "EqualSubstringString", runFunction: run_EqualSubstringString, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "EqualSubstringSubstring", runFunction: run_EqualSubstringSubstring, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "EqualSubstringSubstringGenericEquatable", runFunction: run_EqualSubstringSubstringGenericEquatable, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "SubstringDropFirst1", runFunction: run_SubstringDropFirst1, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "SubstringDropLast1", runFunction: run_SubstringDropLast1, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "SubstringRemoveFirst1", runFunction: run_SubstringRemoveFirst1, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "SubstringRemoveLast1", runFunction: run_SubstringRemoveLast1, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "LessSubstringSubstring", runFunction: run_LessSubstringSubstring, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "LessSubstringSubstringGenericComparable", runFunction: run_LessSubstringSubstringGenericComparable, tags: [.validation, .api, .String]),
BenchmarkInfo(name: "StringFromLongWholeSubstring", runFunction: run_StringFromLongWholeSubstring, tags: [.validation, .api, .String]),
Expand All @@ -36,7 +36,7 @@ let longWide = "fὢasὢodὢijὢadὢolὢsjὢalὢsdὢjlὢasὢdfὢijὢ
let (s1, ss1) = equivalentWithDistinctBuffers()
let (s2, ss2) = equivalentWithDistinctBuffers()

let quiteLong = String(repeating: "0", count: 15_000)[...]
let quiteLong = String(repeating: "0", count: 10_000)[...]

@inline(never)
public func run_SubstringFromLongString(_ N: Int) {
Expand Down Expand Up @@ -131,18 +131,20 @@ public func run_EqualSubstringSubstringGenericEquatable(_ N: Int) {
}

@inline(never)
public func run_SubstringDropFirst1(_ N: Int) {
let s = quiteLong
for _ in 1...N*1000 {
blackHole(!s.dropFirst(1).isEmpty)
public func run_SubstringRemoveFirst1(_ N: Int) {
for _ in 1...N {
var s = quiteLong
s.removeFirst(1)
blackHole(s.first == "0")
}
}

@inline(never)
public func run_SubstringDropLast1(_ N: Int) {
let s = quiteLong
for _ in 1...N*1000 {
blackHole(!s.dropLast(1).isEmpty)
public func run_SubstringRemoveLast1(_ N: Int) {
for _ in 1...N {
var s = quiteLong
s.removeLast(1)
blackHole(s.first == "0")
}
}

Expand Down