• iOS.GetCurrentTimestamp


    Cocoa 中测量时间的方法 

    1. The Methods to Get Current Timestamp

    iOS中获取时间戳的方法:

    A. CACurrentMediaTime()

    B. gettimeofday

    C. CFAbsoluteTimeGetCurrent

    D. [NSDate date] timeIntervalSince1970]

    E. mach_absolute_time() 

    Ref[1]对比了以上方法的耗时,但是其准确性需要验证。

    2. Clock Time

    时钟时间

    "CFAbsoluteTimeGetCurrent [NSDate timeIntervalSinceReferenceDate] return clock time.

    Clock time is synchronized with the network time signal. So, they are not suitable for timestamp." Ref[2]

    3. 各种方法的对比以及适用场景

    3.1 对于测量App中某些操作的所消耗的时间,用CACurrentMediaTime()来说很合适。


    Reference

    1. http://stackoverflow.com/questions/358207/iphone-how-to-get-current-milliseconds

    2. Tip: CACurrentMediaTime

    http://www.alexcurylo.com/blog/2009/09/05/tip-cacurrentmediatime/

    3. iOS.mach_absolute_time

    4. Benchmarking

    http://nshipster.com/benchmarking/

    http://nshipster.cn/benchmarking/

    5. ‘CACurrentMediaTime()’

    http://bendodson.com/weblog/2013/01/29/ca-current-media-time/


    Todo

    1. Timers, Clocks, and Cocoa

    http://devetc.org/code/2014/01/21/timers-clocks-and-cocoa.html

    2. 

    http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=1019

    3. All in the Timing: Keeping Track of Time Passed on iOS

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

    4. How to convert mach_absolute_time() into seconds?

    ---
  • 相关阅读:
    Javascript DMO 编程艺术
    PHPExcel
    MYSQL
    AJAX全接触
    正则表达式
    常用知识
    PHP 常用函数
    thinkphp5 公共函数的使用与调用
    thinkphp 使用phpExcel 导入和导出
    php 判断是pc端还是移动端
  • 原文地址:https://www.cnblogs.com/cwgk/p/3818853.html
Copyright © 2020-2023  润新知