如何在iPhone上访问比1秒更短的系统时间

wil*_*lc2 9 iphone time

系统时间函数时间(0)给出了1秒的分辨率,对吧?

是否有更细粒度的功能?

我用它来确定两个事件之间的时间间隔.

一行代码对我很有帮助.当我查看官方文档时,它可以更容易地将一些具体内容挂起来.

zou*_*oul 17

请参阅CFAbsoluteTimeGetCurrent:

CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
// do something you want to measure
CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
NSLog(@"operation took %2.5f seconds", end-start);
Run Code Online (Sandbox Code Playgroud)

如果你发现CFAbsouteTime太冗长,你可以简单地使用double.