marten 0 Newbie Poster

I need to calculate the time of execution in millisecond, and this function should beAcurrate as possible.

I asked one of my friends and he gave me one good function that do that and
accurate, but there is linking Error, because this function works under Linux
and I am works under wondows using MinGW32.

Please, Can you help me to run this program???

The Linking Error is :-
undefined reference to `gettimeofday'

///////////My Program is:-

#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <windows.h>
#include<C:\GNU\1.0\local\include\gmp.h>

double get_time(void);
// real timestamping
double get_time(void)
{
struct timeval stime;
gettimeofday (&stime, (struct timezone*)0);
return (stime.tv_sec+((double)stime.tv_usec)/1000000);
}

main()
{
double t_se, t_fe;
t_se=get_time();
// do someting
t_fe=get_time();
printf("Encryption Time = %8.4lfms\n", (t_fe-t_se)*1000);
}

Thanks in Advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.