Rashmi.L.shetty
Rashmi.L.shetty

Reputation: 21

Find how long my methods take to execute

How can I find out which of my methods take the most time to execute in my iPad application?

Upvotes: 0

Views: 172

Answers (2)

Saroj
Saroj

Reputation: 656

For better CPU analysis, you should use Time profiler in XCode Instruments.

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

Upvotes: 1

Mutawe
Mutawe

Reputation: 6524

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

Upvotes: 1

Related Questions