Last active
March 13, 2023 14:51
-
-
Save andresr-dev/a2d7b21fe8138b8234c5021b1f2d33eb to your computer and use it in GitHub Desktop.
This is how to measure time execution in swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let clock = ContinuousClock() | |
| let start = clock.now | |
| // Do some heavy calculation... | |
| print("Took \(start.duration(to: .now))") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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