🐶

【Swift】最もシンプルに実行時間を計測する

2024/06/22に公開
let start = Date()
try? await Task.sleep(for: .milliseconds(1234))
let end = -start.timeIntervalSinceNow
print(String(format: "%.3f", end))
// 1.246

🙆🏻‍♂️ 引用

https://android.benigumo.com/20240622/mesure-execution-time/
https://android.benigumo.com/20240521/common-string-format/

Discussion