I;m trying to write a function that returns elapsed time in milliseconds. from the developer decimation it looks like I should use SuspendingClock. But beyond that I haven't got a clue. Any suggestions?
If you subtract two suspending clock instants you get a Duration value:
let c = SuspendingClock()
let start = c.now
… your code here …
let end = c.now
let delta: Duration = end - start
That’s a 128-bit count of attoseconds. Use the components property to get seconds and attoseconds:
let (seconds, attoseconds) = delta.components
You can tidy this up with the measure(_:) method`:
let delta = c.measure {
… your code here …
}
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"