0

如何找出我的哪些方法在我的 iPad 应用程序中执行时间最长?

4

2 回答 2

1

为了更好地进行 CPU 分析,您应该在 XCode Instruments 中使用 Time profiler。

参考http://cocoaforbreakfast.wordpress.com/2011/03/01/time-profiler-when-a-small-change-can-bring-huge-gains/

于 2012-10-10T11:30:14.067 回答
1

Put an NSLogat the beginning of the method and one at the end

the console shows the exact time for the NSLog so thats how you can determine which takes log time

Example:

-(void)buttonsTag{
  NSLog(@"Beginning of buttonsTag Method");
  btn1.tag  =1;
  btn2.tag  =2;
  btn3.tag  =3;
  btn4.tag  =4;
  btn5.tag  =5;
  btn6.tag  =6; 
  btn7.tag  =7;
  btn8.tag  =8;
  btn9.tag  =9;
  btn10.tag =10;

  NSLog(@"End of buttonsTag Method");

}


 //The console output:
 //2012-10-10 14:22:29.308 APP[3691:c07] Beginning of buttonsTag Method
 //2012-10-10 14:22:29.309 APP[3691:c07] End of buttonsTag Method
 //The deference is 14:22:29.309 - 14:22:29.308 = 00:00:00.001
于 2012-10-10T11:18:21.743 回答