Last active
April 15, 2021 14:22
-
-
Save amfathi/5a3a16ab9a1ab0eebe68162eb1002d05 to your computer and use it in GitHub Desktop.
A utility function to calculate and print the running time for a code block in milliseconds.
This file contains 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
func runningTime(clousure: () -> Void) { | |
let start = DispatchTime.now() | |
clousure() | |
let end = DispatchTime.now() | |
let runTime = CLongDouble(end.uptimeNanoseconds - start.uptimeNanoseconds) / 1e6 | |
print("runTime: \(runTime) ms") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment