Timing Your Application
How fast your application executes is one indication of performance.
When timing the speed of applications, consider the following circumstances:
- Run program timings when other users are not active.
Your timing results can be affected by one or more CPU-intensive processes
also running while doing your timings.
- Try to run the program under the same conditions
each time to provide the most accurate results, especially when comparing
execution times of a previous version of the same program. Use the same
system (processor model, amount of memory, version of the operating system,
and so on) if possible.
- If you do need to change systems, you should measure
the time using the same version of the program on both systems, so you
know each system's effect on your timings.
- For programs that run for less than a few seconds,
run several timings to ensure that the results are not misleading. Certain
overhead functions, like loading external programs, might influence short
- If your program displays a lot of text, consider
redirecting the output from the program. Redirecting output from the program
will change the times reported because of reduced screen I/O.
The following program illustrates a model for program timing:
/* Sample Timing */
loop <= 2000; loop++)
= 123.456 * 789;
inculded to facilitate example
value of loop is: %d", loop);
= (double)(finish - start)/CLOCKS_PER_SEC;