Timing Your Application

You can start collecting information about your application performance with simply timing your application. More sophisticated and helpful data can be collected by using performance analyzing tools.

Considerations on Timing Your Application

One of the performance indicators is your application timing. The following considerations apply to timing your application:

The following program illustrates a model for program timing:

Example

/* 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() included 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);

}