Merge pull request #150 from Janiels/fix-windows-timing
Fix time measuring on Windows
This commit is contained in:
commit
5a342b83e8
@ -27,6 +27,6 @@ typedef __int64 TimeVal;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TimeVal getPerfTime();
|
TimeVal getPerfTime();
|
||||||
int getPerfDeltaTimeUsec(const TimeVal start, const TimeVal end);
|
int getPerfTimeUsec(const TimeVal duration);
|
||||||
|
|
||||||
#endif // PERFTIMER_H
|
#endif // PERFTIMER_H
|
@ -30,7 +30,7 @@
|
|||||||
class BuildContext : public rcContext
|
class BuildContext : public rcContext
|
||||||
{
|
{
|
||||||
TimeVal m_startTime[RC_MAX_TIMERS];
|
TimeVal m_startTime[RC_MAX_TIMERS];
|
||||||
int m_accTime[RC_MAX_TIMERS];
|
TimeVal m_accTime[RC_MAX_TIMERS];
|
||||||
|
|
||||||
static const int MAX_MESSAGES = 1000;
|
static const int MAX_MESSAGES = 1000;
|
||||||
const char* m_messages[MAX_MESSAGES];
|
const char* m_messages[MAX_MESSAGES];
|
||||||
|
@ -854,7 +854,7 @@ void CrowdToolState::updateTick(const float dt)
|
|||||||
m_agentDebug.vod->normalizeSamples();
|
m_agentDebug.vod->normalizeSamples();
|
||||||
|
|
||||||
m_crowdSampleCount.addSample((float)crowd->getVelocitySampleCount());
|
m_crowdSampleCount.addSample((float)crowd->getVelocitySampleCount());
|
||||||
m_crowdTotalTime.addSample(getPerfDeltaTimeUsec(startTime, endTime) / 1000.0f);
|
m_crowdTotalTime.addSample(getPerfTimeUsec(endTime - startTime) / 1000.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,13 +30,12 @@ TimeVal getPerfTime()
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPerfDeltaTimeUsec(const TimeVal start, const TimeVal end)
|
int getPerfTimeUsec(const TimeVal duration)
|
||||||
{
|
{
|
||||||
static __int64 freq = 0;
|
static __int64 freq = 0;
|
||||||
if (freq == 0)
|
if (freq == 0)
|
||||||
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
|
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
|
||||||
__int64 elapsed = end - start;
|
return (int)(duration*1000000 / freq);
|
||||||
return (int)(elapsed*1000000 / freq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -52,9 +51,9 @@ TimeVal getPerfTime()
|
|||||||
return (TimeVal)now.tv_sec*1000000L + (TimeVal)now.tv_usec;
|
return (TimeVal)now.tv_sec*1000000L + (TimeVal)now.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPerfDeltaTimeUsec(const TimeVal start, const TimeVal end)
|
int getPerfTimeUsec(const TimeVal duration)
|
||||||
{
|
{
|
||||||
return (int)(end - start);
|
return (int)duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -79,7 +79,7 @@ void BuildContext::doStopTimer(const rcTimerLabel label)
|
|||||||
|
|
||||||
int BuildContext::doGetAccumulatedTime(const rcTimerLabel label) const
|
int BuildContext::doGetAccumulatedTime(const rcTimerLabel label) const
|
||||||
{
|
{
|
||||||
return m_accTime[label];
|
return getPerfTimeUsec(m_accTime[label]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildContext::dumpLog(const char* format, ...)
|
void BuildContext::dumpLog(const char* format, ...)
|
||||||
|
@ -215,7 +215,7 @@ void TestCase::doTests(dtNavMesh* navmesh, dtNavMeshQuery* navquery)
|
|||||||
navquery->findNearestPoly(iter->epos, polyPickExt, &filter, &endRef, iter->nepos);
|
navquery->findNearestPoly(iter->epos, polyPickExt, &filter, &endRef, iter->nepos);
|
||||||
|
|
||||||
TimeVal findNearestPolyEnd = getPerfTime();
|
TimeVal findNearestPolyEnd = getPerfTime();
|
||||||
iter->findNearestPolyTime += getPerfDeltaTimeUsec(findNearestPolyStart, findNearestPolyEnd);
|
iter->findNearestPolyTime += getPerfTimeUsec(findNearestPolyEnd - findNearestPolyStart);
|
||||||
|
|
||||||
if (!startRef || ! endRef)
|
if (!startRef || ! endRef)
|
||||||
continue;
|
continue;
|
||||||
@ -228,7 +228,7 @@ void TestCase::doTests(dtNavMesh* navmesh, dtNavMeshQuery* navquery)
|
|||||||
navquery->findPath(startRef, endRef, iter->spos, iter->epos, &filter, polys, &iter->npolys, MAX_POLYS);
|
navquery->findPath(startRef, endRef, iter->spos, iter->epos, &filter, polys, &iter->npolys, MAX_POLYS);
|
||||||
|
|
||||||
TimeVal findPathEnd = getPerfTime();
|
TimeVal findPathEnd = getPerfTime();
|
||||||
iter->findPathTime += getPerfDeltaTimeUsec(findPathStart, findPathEnd);
|
iter->findPathTime += getPerfTimeUsec(findPathEnd - findPathStart);
|
||||||
|
|
||||||
// Find straight path
|
// Find straight path
|
||||||
if (iter->npolys)
|
if (iter->npolys)
|
||||||
@ -238,7 +238,7 @@ void TestCase::doTests(dtNavMesh* navmesh, dtNavMeshQuery* navquery)
|
|||||||
navquery->findStraightPath(iter->spos, iter->epos, polys, iter->npolys,
|
navquery->findStraightPath(iter->spos, iter->epos, polys, iter->npolys,
|
||||||
straight, 0, 0, &iter->nstraight, MAX_POLYS);
|
straight, 0, 0, &iter->nstraight, MAX_POLYS);
|
||||||
TimeVal findStraightPathEnd = getPerfTime();
|
TimeVal findStraightPathEnd = getPerfTime();
|
||||||
iter->findStraightPathTime += getPerfDeltaTimeUsec(findStraightPathStart, findStraightPathEnd);
|
iter->findStraightPathTime += getPerfTimeUsec(findStraightPathEnd - findStraightPathStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy results
|
// Copy results
|
||||||
@ -270,7 +270,7 @@ void TestCase::doTests(dtNavMesh* navmesh, dtNavMeshQuery* navquery)
|
|||||||
navquery->raycast(startRef, iter->spos, iter->epos, &filter, &t, hitNormal, polys, &iter->npolys, MAX_POLYS);
|
navquery->raycast(startRef, iter->spos, iter->epos, &filter, &t, hitNormal, polys, &iter->npolys, MAX_POLYS);
|
||||||
|
|
||||||
TimeVal findPathEnd = getPerfTime();
|
TimeVal findPathEnd = getPerfTime();
|
||||||
iter->findPathTime += getPerfDeltaTimeUsec(findPathStart, findPathEnd);
|
iter->findPathTime += getPerfTimeUsec(findPathEnd - findPathStart);
|
||||||
|
|
||||||
if (t > 1)
|
if (t > 1)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user