polserver/pol-core/clib/wallclock.cpp

46 lines
638 B
C++
Raw Permalink Normal View History

/** @file
*
* @par History
*/
2016-02-11 22:54:43 +01:00
#include "wallclock.h"
#ifndef _WIN32
#include <sys/time.h>
2018-02-04 14:10:23 +01:00
#else
#include <ctime>
2016-02-11 22:54:43 +01:00
#endif
namespace Pol
{
namespace Clib
{
2016-02-11 22:54:43 +01:00
#ifdef _WIN32
wallclock_t wallclock()
{
return clock();
}
wallclock_diff_t wallclock_diff_ms( wallclock_t start, wallclock_t finish )
{
return ( ( finish - start ) * 1000L / CLOCKS_PER_SEC );
}
2016-02-11 22:54:43 +01:00
#else
wallclock_t wallclock()
{
struct timeval tmv;
struct timezone tz;
gettimeofday( &tmv, &tz );
return ( tmv.tv_sec ) * 1000 + tmv.tv_usec / 1000L;
}
wallclock_diff_t wallclock_diff_ms( wallclock_t start, wallclock_t finish )
{
return finish - start;
}
2016-02-11 22:54:43 +01:00
#endif
}
2016-02-11 22:54:43 +01:00
}