The difference between nsdate, cfabsolutetimegetcurrent and Cacurrentmediatime

Source: Internet
Author: User


Frame layer:

NSDate belongs to Foundation

Cfabsolutetimegetcurrent () belongs to Corefoundatio

Cacurrentmediatime () belongs to Quartzcore


Essential differences:

NSDateor an CFAbsoluteTimeGetCurrent() 返回的时钟时间将会会网络时间同步,从时钟 offset angle, mach_absolute_time() and CACurrentMediaTime() is based on the built-in clock, can be measured more accurately and atomically, and will not change due to external time changes (such as time zone changes, summer time, second mutation, etc.), but it is related to the uptime of the system, Cacurrentmediatime () will be reset after the system restarts.


Common usage:

NSDate, CFAbsoluteTimeGetCurrent () commonly used for the representation of daily time, timestamp, and data interaction with the server

where Cfabsolutetimegetcurrent () corresponds to [[NSDate data] timeintervalsincereferencedate];

Cacurrentmediatime () often used to test the efficiency of code


Reference article:

http://nshipster.cn/benchmarking/

http://blog.spacemanlabs.com/2011/09/all-in-the-timing-keeping-track-of-time-passed-on-ios/




The difference between nsdate, cfabsolutetimegetcurrent and Cacurrentmediatime

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.