Business performance monitoring for IOS performance optimization

Source: Internet
Author: User

Business performance monitoring, at the beginning and end of the business to manage the report, and then the background statistics to achieve monitoring purposes,

is one of the more important dimensions in performance optimization. In particular, the time loss for the execution of the test method operation, which may be synchronous

It can also be asynchronous. There are about five ways to test:

First: NSDate accuracy may be microseconds (μs)

nsdate* tmpstartdata = [NSDate date]; // You code here ... double deltatime = [[nsdate Date] timeintervalsincedate:tmpstartdata]; NSLog (@ "cost time=%f s", deltatime);

Second type: clock_t accuracy may be microseconds (μs)

clock_t start = clock (); // dosomething  = clock (); NSLog (@ " time loss%f s", (double

The third type:cfabsolutetime accuracy may be microseconds (μs)

Cfabsolutetime start = cfabsolutetimegetcurrent (); // You code here ... Cfabsolutetime end = cfabsolutetimegetcurrent (); NSLog (@ "cost time=%f s"

Fourth type: Cftimeinterval accuracy nanosecond (ns)

Cftimeinterval start = cacurrentmediatime (); // dosomething  = cacurrentmediatime (); NSLog (@ " time loss =%f s"

Fifth type: Mach_absolute_time accuracy nanosecond (ns)

  uint64_t start = mach_absolute_time ();  Operation ();   = mach_absolute_time ();   = 1e-9

The above five methods, the actual available is the last two, what are the five kinds of relationship?

NSDate, Gettimeofday, Mach_absolute_time

That is to say, the final source is Mach_absolute_time, the time synchronization mechanism that Gettimeofday joins.

csdn:http://blog.csdn.net/skymingst/article/details/41892445

Mach_absolute_time detailed

http://southpeak.github.io/blog/2014/09/23/xing-neng-yu-shi-jian/

clock_t is unreliable.

Http://www.cnblogs.com/chenyadong/archive/2011/12/03/2274783.html

Appendix:

Mach_absolute_time more stringent time detection methods see sample code, intermediate reference to the official QA sample

Characteristics:

1. Added block form support-not recommended for use with t_t

2. Support Unit Test Header output

3. Supports synchronous, asynchronous testing

4. Nanosecond accuracy, default is millisecond output, precision microsecond

Https://github.com/skyming/iOS-Performance-Optimization

Starting:

http://skyming.me/2016/05/08/iOS-Performance-Optimization-Time-md/

Business performance monitoring for IOS performance optimization

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.