Last active
March 4, 2020 08:10
-
-
Save cemolcay/e8e3cad64da65cd80a50ed37310d2038 to your computer and use it in GitHub Desktop.
mach_absolute_time to seconds 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
var timebaseInfo = mach_timebase_info_data_t() | |
init() { | |
mach_timebase_info(&timebaseInfo) | |
} | |
func machAbsoluteToSeconds(machAbsolute: UInt64 = mach_absolute_time()) -> Double { | |
let nanos = Double(machAbsolute * UInt64(timebaseInfo.numer)) / Double(timebaseInfo.denom) | |
return nanos / 1.0e9; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment