Code to measure EXACT execution time inside code on iPad or Phone?

前端 未结 2 659
醉梦人生
醉梦人生 2021-01-31 04:28

Is is any difference between using mach_absolute_time and the simple NSDate method explained by golden eagle below?

Here\'s an excellen

2条回答
  •  长情又很酷
    2021-01-31 05:14

    loop
      {
       NSDate *start = [NSDate date];
    
      // a considerable amount of difficult processing here
      // a considerable amount of difficult processing here
      // a considerable amount of difficult processing here
    
       NSDate *methodFinish = [NSDate date];
       NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:start];
    
       NSLog(@"Execution Time: %f", executionTime);
      }
    

    Should work.

提交回复
热议问题