用于衡量iPad或手机代码内的完整执行时间的代码? [英] Code to measure EXACT execution time inside code on iPad or Phone?

查看:95
本文介绍了用于衡量iPad或手机代码内的完整执行时间的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 mach_absolute_time 与下面的金鹰解释的简单 NSDate 方法有什么区别?

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

以下是使用mach方法的一个很好的解释......

Here's an excellent explanation of using the mach approach...

如何准确计算在iPhone上调用功能所需的时间?

测量库调用和回调之间的时间

推荐答案

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);
  }

应该有效。

这篇关于用于衡量iPad或手机代码内的完整执行时间的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆