hello everyone.
i m monjuri. i want to find out the execution time of a C program. it works fine. but i want the time in milisecond or microsecond. Can anybody help me???
here is my code:
/*insertion code*/
#include <stdio.h>
#include <time.h>
#define maxsize 10
int A[maxsize];
int value,j,i;
insertionSort(int A[],int s){
int i, j, t;
for (i=1; i<s; i++)
{
j=i;
t=A[j];
while (j>0 && A[j-1]>t)
{
A[j]=A[j-1];
j--;
}
A[j]=t;
}
}
void printarr(int a)
{
int i;
for(i=0;i<a;i++)
{
printf("%d",A[i]);
printf("\n");
}
}
//Global Variables
double timer;
double timer2;
void startTimer()
{
timer = clock();
}
double stopTimer()
{
timer2 = clock();
timer = timer2 - timer;
return timer;
}
main()
{
int i,s;
double time;
printf("enter the number of numbers to be entered \n");
scanf("%d",&s);
for(i=0;i<s;i++)
{
printf("enter the number \n" );
scanf("%d",&A[i]);
}
printf("array before sorting ");
printarr(s);
insertionSort(A,s);
printf("array after sorting");
printarr(s);
startTimer();
time= stopTimer();
printf(" the execution time %lf",time);
}
Thank u.