Skip to content

Commit 65574bc

Browse files
committed
Include everything
1 parent 4e7b7d1 commit 65574bc

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

0127-parsing-performance-pt1/parser-performance.playground/Contents.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,22 @@ acuteE1.unicodeScalars.elementsEqual(acuteE2.unicodeScalars)
3333
"🇸"
3434
"🇺" + "🇸"
3535
"\u{1F1FA}\u{1F1F8}"
36+
37+
38+
39+
"🇺🇸".dropFirst()
40+
41+
String("🇺🇸".unicodeScalars.dropFirst())
42+
43+
Array(acuteE1.utf8)
44+
Array(acuteE2.utf8)
45+
46+
Array("🇺🇸".unicodeScalars)
47+
Array("🇺🇸".utf8)
48+
Array("👨‍👨‍👧‍👧".unicodeScalars)
49+
Array("👨‍👨‍👧‍👧".utf8)
50+
"👨‍👨‍👧‍👧".utf8.count
51+
52+
"🇺🇸".unicodeScalars.first == ("🇺" as Unicode.Scalar)
53+
54+
"🇺🇸".utf8.starts(with: [240, 159, 135, 186])

0127-parsing-performance-pt1/string-performance/Sources/string-performance/Benchmark-Copying.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Benchmark
22

33
let copyingSuite = BenchmarkSuite(name: "Copying") { suite in
4-
let string = String.init(repeating: "A", count: 1_000_000)
4+
let string = String.init(repeating: "👨‍👨‍👧‍👧", count: 1_000_000)
55

66
suite.benchmark("String") {
77
var copy = string
@@ -24,5 +24,27 @@ let copyingSuite = BenchmarkSuite(name: "Copying") { suite in
2424
var copy3 = copy2
2525
copy3.removeFirst()
2626
}
27+
28+
suite.benchmark("UnicodeScalars") {
29+
var copy = string[...].unicodeScalars
30+
copy.removeFirst()
31+
var copy1 = copy
32+
copy1.removeFirst()
33+
var copy2 = copy1
34+
copy2.removeFirst()
35+
var copy3 = copy2
36+
copy3.removeFirst()
37+
}
38+
39+
suite.benchmark("UTF8") {
40+
var copy = string[...].utf8
41+
copy.removeFirst()
42+
var copy1 = copy
43+
copy1.removeFirst()
44+
var copy2 = copy1
45+
copy2.removeFirst()
46+
var copy3 = copy2
47+
copy3.removeFirst()
48+
}
2749
}
2850

0 commit comments

Comments
 (0)