Skip to content

Commit

Permalink
Include everything
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Dec 3, 2020
1 parent 4e7b7d1 commit 65574bc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,22 @@ acuteE1.unicodeScalars.elementsEqual(acuteE2.unicodeScalars)
"πŸ‡Έ"
"πŸ‡Ί" + "πŸ‡Έ"
"\u{1F1FA}\u{1F1F8}"



"πŸ‡ΊπŸ‡Έ".dropFirst()

String("πŸ‡ΊπŸ‡Έ".unicodeScalars.dropFirst())

Array(acuteE1.utf8)
Array(acuteE2.utf8)

Array("πŸ‡ΊπŸ‡Έ".unicodeScalars)
Array("πŸ‡ΊπŸ‡Έ".utf8)
Array("πŸ‘¨β€πŸ‘¨β€πŸ‘§β€πŸ‘§".unicodeScalars)
Array("πŸ‘¨β€πŸ‘¨β€πŸ‘§β€πŸ‘§".utf8)
"πŸ‘¨β€πŸ‘¨β€πŸ‘§β€πŸ‘§".utf8.count

"πŸ‡ΊπŸ‡Έ".unicodeScalars.first == ("πŸ‡Ί" as Unicode.Scalar)

"πŸ‡ΊπŸ‡Έ".utf8.starts(with: [240, 159, 135, 186])
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Benchmark

let copyingSuite = BenchmarkSuite(name: "Copying") { suite in
let string = String.init(repeating: "A", count: 1_000_000)
let string = String.init(repeating: "πŸ‘¨β€πŸ‘¨β€πŸ‘§β€πŸ‘§", count: 1_000_000)

suite.benchmark("String") {
var copy = string
Expand All @@ -24,5 +24,27 @@ let copyingSuite = BenchmarkSuite(name: "Copying") { suite in
var copy3 = copy2
copy3.removeFirst()
}

suite.benchmark("UnicodeScalars") {
var copy = string[...].unicodeScalars
copy.removeFirst()
var copy1 = copy
copy1.removeFirst()
var copy2 = copy1
copy2.removeFirst()
var copy3 = copy2
copy3.removeFirst()
}

suite.benchmark("UTF8") {
var copy = string[...].utf8
copy.removeFirst()
var copy1 = copy
copy1.removeFirst()
var copy2 = copy1
copy2.removeFirst()
var copy3 = copy2
copy3.removeFirst()
}
}

0 comments on commit 65574bc

Please sign in to comment.