added computation of elapsed msec

This commit is contained in:
Evghenii
2014-02-20 12:30:51 +01:00
parent d6b04c58e8
commit d4c6209aa0

View File

@@ -58,6 +58,7 @@ __inline__ uint64_t rdtsc() {
#ifdef WIN32
#include <windows.h>
double rtc();
#define rdtsc __rdtsc
#else // WIN32
__inline__ uint64_t rdtsc() {
@@ -72,14 +73,30 @@ __inline__ uint64_t rdtsc() {
__asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high));
return (uint64_t)high << 32 | low;
}
#include <sys/time.h>
static inline double rtc(void)
{
struct timeval Tvalue;
double etime;
struct timezone dummy;
gettimeofday(&Tvalue,&dummy);
etime = (double) Tvalue.tv_sec +
1.e-6*((double) Tvalue.tv_usec);
return etime;
}
#endif // !WIN32
#endif // !__arm__
static uint64_t start, end;
static uint64_t start, end;
static double tstart, tend;
static inline void reset_and_start_timer()
{
start = rdtsc();
tstart = rtc();
}
/* Returns the number of millions of elapsed processor cycles since the
@@ -89,3 +106,9 @@ static inline double get_elapsed_mcycles()
end = rdtsc();
return (end-start) / (1024. * 1024.);
}
static inline double get_elapsed_msec()
{
tend = rtc();
return (tend - tstart)*1e3;
}