mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2025-02-18 07:50:04 +01:00
gettimeofday is not reliable on PANDORA, so use clock_gettime instead
This commit is contained in:
parent
ddb0e94ef2
commit
4bfca131b8
@ -28,9 +28,15 @@ template class CStaticArray<CProfileTimer>;
|
|||||||
static inline __int64 ReadTSC_profile(void)
|
static inline __int64 ReadTSC_profile(void)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined USE_PORTABLE_C)
|
||||||
|
#ifdef __arm__
|
||||||
|
struct timespec tv;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &tv);
|
||||||
|
return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_nsec) / 1000000) );
|
||||||
|
#else
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_usec) / 1000) );
|
return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_usec) / 1000) );
|
||||||
|
#endif
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
#elif (defined __MSVC_INLINE__)
|
||||||
__int64 mmRet;
|
__int64 mmRet;
|
||||||
|
@ -28,9 +28,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <Engine/Base/ListIterator.inl>
|
#include <Engine/Base/ListIterator.inl>
|
||||||
#include <Engine/Base/Priority.inl>
|
#include <Engine/Base/Priority.inl>
|
||||||
|
|
||||||
//#if ( (USE_PORTABLE_C) || (PLATFORM_UNIX) )
|
#if (USE_PORTABLE_C)
|
||||||
//#define USE_GETTIMEOFDAY 1
|
#define USE_GETTIMEOFDAY 1
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
#if USE_GETTIMEOFDAY
|
#if USE_GETTIMEOFDAY
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -40,10 +40,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
static inline __int64 ReadTSC(void)
|
static inline __int64 ReadTSC(void)
|
||||||
{
|
{
|
||||||
#if USE_GETTIMEOFDAY
|
#if USE_GETTIMEOFDAY
|
||||||
|
#ifdef PANDORA
|
||||||
|
struct timespec tp;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||||
|
return( (((__int64) tp.tv_sec) * 1000000000LL) + ((__int64) tp.tv_nsec));
|
||||||
|
#else
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
return( (((__int64) tv.tv_sec) * 1000000) + ((__int64) tv.tv_usec) );
|
return( (((__int64) tv.tv_sec) * 1000000) + ((__int64) tv.tv_usec) );
|
||||||
|
#endif
|
||||||
#elif (defined __MSVC_INLINE__)
|
#elif (defined __MSVC_INLINE__)
|
||||||
__int64 mmRet;
|
__int64 mmRet;
|
||||||
__asm {
|
__asm {
|
||||||
@ -315,7 +320,11 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/)
|
|||||||
|
|
||||||
#if USE_GETTIMEOFDAY
|
#if USE_GETTIMEOFDAY
|
||||||
// just use gettimeofday.
|
// just use gettimeofday.
|
||||||
|
#ifdef PANDORA
|
||||||
|
tm_llCPUSpeedHZ = tm_llPerformanceCounterFrequency = 1000000000LL;
|
||||||
|
#else
|
||||||
tm_llCPUSpeedHZ = tm_llPerformanceCounterFrequency = 1000000;
|
tm_llCPUSpeedHZ = tm_llPerformanceCounterFrequency = 1000000;
|
||||||
|
#endif
|
||||||
|
|
||||||
#elif PLATFORM_WIN32
|
#elif PLATFORM_WIN32
|
||||||
{ // this part of code must be executed as precisely as possible
|
{ // this part of code must be executed as precisely as possible
|
||||||
|
Loading…
x
Reference in New Issue
Block a user