In addition to Time Profiler, as Dan suggests, you can also use the Sampler tool, which usually stops the program at set intervals and writes information about the stack trace for each program stream. You can use this information to determine where the runtime is spent in your program, and to improve the code to reduce run time.
The main difference between the sampler and time sampler:
Sampler , Time Profiler / .