Skip to content

Instantly share code, notes, and snippets.

@andresr-dev
Last active March 13, 2023 14:51
Show Gist options
  • Select an option

  • Save andresr-dev/a2d7b21fe8138b8234c5021b1f2d33eb to your computer and use it in GitHub Desktop.

Select an option

Save andresr-dev/a2d7b21fe8138b8234c5021b1f2d33eb to your computer and use it in GitHub Desktop.
This is how to measure time execution in swift
let clock = ContinuousClock()
let start = clock.now
// Do some heavy calculation...
print("Took \(start.duration(to: .now))")
let clock = ContinuousClock()
let time = clock.measure {
// complex work here
}
print("Took \(time.components.seconds) seconds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment