The document you reference notes that mach_absolute_time
is CPU dependent, so we can't say how much time must elapse before it wraps. On the simulator, mach_absolute_time
is nanoseconds, so if it's wrapping at UInt64.max
, that translates to 585 years. On my iPhone 7+, it's 24,000,000 mac_absolute_time
per second, which translates to 24 thousand years. Bottom line, the theoretical maximum amount of time captured by mach_absolute_time
will vary based upon CPU, but you won't ever encounter this in any practical application.
For what it's worth, consistent with those various posts you found, the CFAbsoluteTimeGetCurrent
documentation warns that:
Repeated calls to this function do not guarantee monotonically increasing results. The system time may decrease due to synchronization with external time references or due to an explicit user change of the clock.
So, you definitely don't want to use NSDate
/Date
or CFAbsoluteTimeGetCurrent
if you want accurate elapsed times. Neither ensures monotonically increasing values.
In short, when I need that sort of behavior, I generally use CACurrentMediaTime
, because it enjoy the benefits of mach_absolute_time
, but it converts it to seconds for me, which makes it very simple to use. And neither it nor mach_absolute_time
are going to loop in any realistic time period.