How fast your application executes is one indication of performance. When timing the speed of applications, consider the following circumstances:
The following program illustrates a model for program timing:
Sample Timing |
---|
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { clock_t start, finish; long loop; double duration, loop_calc; start = clock(); for(loop=0; loop <= 2000; loop++) { loop_calc = 123.456 * 789;
//printf() inculded to facilitate example printf("\nThe value of loop is: %d", loop); } finish = clock(); duration = (double)(finish - start)/CLOCKS_PER_SEC; printf("\n%2.3f seconds\n", duration); } |