コード例 #1
0
ファイル: llfasttimer.cpp プロジェクト: 9skunks/imprudence
void LLFastTimer::reset()
{
	countsPerSecond(); // good place to calculate clock frequency
	
	if (sCurDepth != 0)
	{
		llerrs << "LLFastTimer::Reset() when sCurDepth != 0" << llendl;
	}
	if (sPauseHistory)
	{
		sResetHistory = 1;
	}
	else if (sResetHistory)
	{
		sCurFrameIndex = -1;
		sResetHistory = 0;
	}
	else if (sCurFrameIndex >= 0)
	{
		int hidx = sCurFrameIndex % FTM_HISTORY_NUM;
		for (S32 i=0; i<FTM_NUM_TYPES; i++)
		{
			sCountHistory[hidx][i] = sCounter[i];
			sCountAverage[i] = (sCountAverage[i]*sCurFrameIndex + sCounter[i]) / (sCurFrameIndex+1);
			sCallHistory[hidx][i] = sCalls[i];
			sCallAverage[i] = (sCallAverage[i]*sCurFrameIndex + sCalls[i]) / (sCurFrameIndex+1);
		}
		sLastFrameIndex = sCurFrameIndex;
	}
	else
	{
		for (S32 i=0; i<FTM_NUM_TYPES; i++)
		{
			sCountAverage[i] = 0;
			sCallAverage[i] = 0;
		}
	}
	
	sCurFrameIndex++;
	
	for (S32 i=0; i<FTM_NUM_TYPES; i++)
	{
		sCounter[i] = 0;
		sCalls[i] = 0;
	}
	sCurDepth = 0;
}
コード例 #2
0
ファイル: pc.c プロジェクト: palmerc/lab
/*
   *********************************************************************************************************
   *                                       ELAPSED TIME INITIALIZATION
   *
   * Description : This function initialize the elapsed time module by determining how long the START and
   *               STOP functions take to execute.  In other words, this function calibrates this module
   *               to account for the processing time of the START and STOP functions.
   *               Needs to be called only once before any of the timers is started with PC_ElapsedStart().
   *
   * Arguments   : None.
   *
   * Returns     : None.
   *********************************************************************************************************
 */
void PC_ElapsedInit(void)
{   static BOOLEAN initDone=FALSE;
    int i;
    
    if (initDone)
    	return;

    printf("INFO: Please wait - timer calibration may take up to 4 secs\n");
    for (i=0; i < 4; i++)
    {    PC_frequency += countsPerSecond();
    }
    PC_frequency = PC_frequency >> 2;
    

    PC_ElapsedOverhead = 0;					// Measure the overhead of PC_ElapsedStart
    PC_ElapsedStart(0);						// ... and PC_ElapsedStop
    PC_ElapsedOverhead = (INT16U) PC_ElapsedStop(0);
    initDone=TRUE;
}