Friday, September 28, 2012

How to see method execution time in XCode?


How to see method execution time in XCode?



Time Profiler is a System Instruments which will tell you where the CPU is spending most of its time.

The Time Profiler instrument stops a Mac OS X program at prescribed intervals and records the stack trace information for each of the program’s threads. You can use this information to determine where execution time is being spent in your program and improve your code to reduce running time. Unlike many instruments, Time Profiler does not require DTrace probes in order to function. Time Profiler operates on a single process or all processes.

During sampling, this instrument captures the following information:

  1. The time at which sampling began
  2. The sampling duration
  3. Stack trace information (including the library and caller information)
  4. The maximum stack depth encountered during sampling
  5. The function encountered most frequently during sampling (the hot frame)
This will helps a lot to determine the root cause of problem such as when a view is loading and it takes too much time to display it.

Apart from Time Profiler one can also use Sampler instrument which generally stops a program at prescribed intervals and records the stack trace information for each of the program’s threads. You can use this information to determine where execution time is being spent in your program and improve your code to reduce running time.

The main difference between sampler & Time profiler :

Sampler instrument operates upon a single process but Time Profiler operates upon a single/All processes.

No comments:

Post a Comment