Hi All
My friend has this problem where he needs to measure the time spent inside
a function in *Milliseconds*. I cant find any libary which allows measuring of time in
milliseconds ? The best is to use the following code
#include <time.h>
static time_t start=NULL;
static time_t stop=NULL;
#define START time(&start)
#define STOP time(&stop)
static void get_time()
{
printf("Time elapsed is %.6lf", difftime(stop, start));
}
START;
function_to_time();
STOP;
get_time();
This code is able to return elapsed time in seconds. Since the function of interest takes much
lesser time than 1 sec, the accuracy has to be in milliseconds.
Any help is appreciated.
Thanks in advance
Anand
My friend has this problem where he needs to measure the time spent inside
a function in *Milliseconds*. I cant find any libary which allows measuring of time in
milliseconds ? The best is to use the following code
#include <time.h>
static time_t start=NULL;
static time_t stop=NULL;
#define START time(&start)
#define STOP time(&stop)
static void get_time()
{
printf("Time elapsed is %.6lf", difftime(stop, start));
}
START;
function_to_time();
STOP;
get_time();
This code is able to return elapsed time in seconds. Since the function of interest takes much
lesser time than 1 sec, the accuracy has to be in milliseconds.
Any help is appreciated.
Thanks in advance
Anand