Commit 2579fd52 authored by Maciej Suminski's avatar Maciej Suminski

Fixed time measuring functions (only for profiling in debug)

parent 733e5a55
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
/** /**
* @file profile.h: * @file profile.h:
* @brief Simple profiling functions for measuring code execution time. Currently only Linux is * @brief Simple profiling functions for measuring code execution time.
* supported.
*/ */
#ifndef __PROFILE_H #ifndef __PROFILE_H
...@@ -91,20 +90,18 @@ static __inline__ unsigned long long rdtsc() ...@@ -91,20 +90,18 @@ static __inline__ unsigned long long rdtsc()
// Fixme: OS X version // Fixme: OS X version
/** /**
* Function get_tics * Function get_tics
* Returns the number of milliseconds that have elapsed since the system was started. * Returns the number of microseconds that have elapsed since the system was started.
* @return uint64_t Number of milliseconds. * @return uint64_t Number of microseconds.
*/ */
static inline uint64_t get_tics() static inline uint64_t get_tics()
{ {
#if defined(__linux__) #if defined(__linux__)
struct timezone tz = { 0, 0 };
struct timeval tv; struct timeval tv;
gettimeofday( &tv, &tz ); gettimeofday( &tv, NULL );
return (uint64_t) tv.tv_sec * 1000000ULL + (uint64_t) tv.tv_usec; return (uint64_t) tv.tv_sec * 1000000ULL + (uint64_t) tv.tv_usec;
#elif defined _WIN32 || defined _WIN64 #elif defined _WIN32 || defined _WIN64
// TODO to be tested return GetTickCount() * 1000;
return GetTickCount();
#else #else
return 0; return 0;
#endif #endif
...@@ -125,7 +122,8 @@ struct prof_counter ...@@ -125,7 +122,8 @@ struct prof_counter
* Begins code execution time counting for a given profiling counter. * Begins code execution time counting for a given profiling counter.
* @param cnt is the counter which should be started. * @param cnt is the counter which should be started.
* @param use_rdtsc tells if processor's time-stamp counter should be used for time counting. * @param use_rdtsc tells if processor's time-stamp counter should be used for time counting.
* Otherwise is system tics method will be used. * Otherwise is system tics method will be used. IMPORTANT: time-stamp counter should not
* be used on multicore machines executing threaded code.
*/ */
static inline void prof_start( prof_counter* cnt, bool use_rdtsc ) static inline void prof_start( prof_counter* cnt, bool use_rdtsc )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment