Skip to content

Commit 6a111d6

Browse files
committed
add string identical benchmark
1 parent d174d92 commit 6a111d6

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

benchmark/single-source/StringTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public var benchmarks: [BenchmarkInfo] {
4949
runFunction: run_iterateWords,
5050
tags: [.validation, .String]))
5151
}
52+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *) {
53+
result.append(
54+
BenchmarkInfo(
55+
name: "StringIdentical",
56+
runFunction: run_StringIdentical,
57+
tags: [.validation, .String]))
58+
}
5259
return result
5360
}
5461

@@ -1676,3 +1683,14 @@ public func run_iterateWords(_ n: Int) {
16761683
blackHole(swiftOrgHTML._words)
16771684
}
16781685
}
1686+
1687+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *)
1688+
public func run_StringIdentical(_ n: Int) {
1689+
let str1 = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. "
1690+
let str2 = str1
1691+
for _ in 0 ..< n {
1692+
for _ in 0 ..< 100_000 {
1693+
check(str1.isIdentical(to: str2))
1694+
}
1695+
}
1696+
}

stdlib/public/core/String.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ extension String {
11121112
}
11131113
}
11141114

1115+
@available(SwiftStdlib 6.3, *)
11151116
extension String {
11161117
/// Returns a boolean value indicating whether this string is identical to
11171118
/// `other`.

stdlib/public/core/Substring.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ extension Substring {
13281328
}
13291329
}
13301330

1331+
@available(SwiftStdlib 6.3, *)
13311332
extension Substring {
13321333
/// Returns a boolean value indicating whether this substring is identical to
13331334
/// `other`.

0 commit comments

Comments
 (0)