Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/LibJXR/image/sys/perfTimerANSI.c view on Meta::CPAN
{
Bool fResult = FALSE;
PERFTIMERTIME iElapsedTime;
if (NULL == pState)
{
// Can happen because we typically ignore errors and use a single bool to
// control all perf timing (some of which can fail to init)
goto exit;
}
// Make sure we are in the right state
if (CS_STOPPED != pState->eState && CS_RUNNING != pState->eState)
{
assert(FALSE);
goto exit;
}
iElapsedTime = pState->iElapsedTime;
if (CS_RUNNING == pState->eState)
{
// Must take a "checkpoint" time reading
fResult = AccumulateTime(pState, &iElapsedTime);
if (FALSE == fResult)
goto exit;
}
// Convert clock ticks to nanoseconds.
// Use floating point for ease of math. If your platform really blows
// with floating point, replace this with appropriate integer calculation
// based on your clock interval.
pResults->iElapsedTime = (PERFTIMERTIME)((float)iElapsedTime *
((float)NANOSECONDS_PER_SECOND / (float)CLOCKS_PER_SEC));
pResults->iTicksPerSecond = CLOCKS_PER_SEC;
pResults->iZeroTimeIntervals = pState->iZeroTimeIntervals;
fResult = TRUE;
exit:
return fResult;
} // PerfTimerGetResults
Bool PerfTimerCopyStartTime(PERFTIMERSTATE *pDestPerfTimer,
PERFTIMERSTATE *pSrcPerfTimer)
{
Bool fResult = FALSE;
if (NULL == pDestPerfTimer)
{
TraceResult(E_INVALIDARG);
goto exit;
}
if (NULL == pSrcPerfTimer)
{
TraceResult(E_INVALIDARG);
goto exit;
}
// Check that both timers are in proper state - both must be running
if (CS_RUNNING != pDestPerfTimer->eState)
{
TraceResult(WM_E_INVALIDSTATE);
goto exit;
}
if (CS_RUNNING != pSrcPerfTimer->eState)
{
TraceResult(WM_E_INVALIDSTATE);
goto exit;
}
if (0 != pDestPerfTimer->iElapsedTime)
{
// If iElapsedTime is non-zero, caller won't get what he is expecting
// when he calls PerfTimerGetResults
TraceResult(WM_E_INVALIDSTATE);
goto exit;
}
pDestPerfTimer->iPrevStartTime = pSrcPerfTimer->iPrevStartTime;
fResult = TRUE;
exit:
return fResult;
} // PerfTimerCopyStartTime
#endif // DISABLE_PERF_MEASUREMENT
( run in 1.189 second using v1.01-cache-2.11-cpan-acebb50784d )