Skip to content

Instantly share code, notes, and snippets.

@kkebo
Last active June 11, 2024 13:17
Show Gist options
  • Save kkebo/daf0592475542c8aef24c70235cd988e to your computer and use it in GitHub Desktop.
Save kkebo/daf0592475542c8aef24c70235cd988e to your computer and use it in GitHub Desktop.
generates a bullet list of https://github.com/kkebo/zyphy/issues/61
import Foundation
let titles = ["lipsum", "lipsum-zh", "medium-fragment", "small-fragment", "tiny-fragment", "strong"]
let html5everResults = "14330 7331.2 31141 3033.7 300.56 18179" // ns
let zyphyResults = "14000 1619 44000 4628 506 20000" // ns
let howSlowers = zip(
html5everResults.split(separator: " ").map { Double($0)! },
zyphyResults.split(separator: " ").map { Double($0)! }
)
.map { $1 / $0 }
for (title, howSlower) in zip(titles, howSlowers) {
if howSlower < 1 / 1.2 {
// faster
print("- ⚡️ \(title): \((1 / howSlower).formatted(.number.precision(.fractionLength(2))))x faster than html5ever")
} else if howSlower < 1 {
// a bit faster
print("- ✅ \(title): \((1 / howSlower).formatted(.number.precision(.fractionLength(2))))x faster than html5ever")
} else if howSlower < 1.2 {
// not so slow
print("- ✅ \(title): \(howSlower.formatted(.number.precision(.fractionLength(2))))x slower than html5ever")
} else {
print("- 🐢 \(title): \(howSlower.formatted(.number.precision(.fractionLength(2))))x slower than html5ever")
}
}
print()
print("(generated by https://gist.github.com/kkebo/daf0592475542c8aef24c70235cd988e)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment