Esempio n. 1
0
void VRSDClient::HandleScriptEventForProfiling(VRSDScriptEvent* pScriptEvent)
{
  if(!pScriptEvent)
    return;

  const char* pFileName = pScriptEvent->pFileName ? pScriptEvent->pFileName : "";
  const char* pFunctionName = pScriptEvent->pFunctionName ? pScriptEvent->pFunctionName : "";
  int iLineDefined = pScriptEvent->iLineDefined;


  // Note: This code is not very memory friendly..
  if(pScriptEvent->eEventType == VRSDScriptEvent::EVENT_ENTER_FUNCTION)
  {
    m_pProfilingStack->Push(new VRSDProfilingSample(pFileName, pFunctionName, pScriptEvent->iLineDefined));
  }
  else if(pScriptEvent->eEventType == VRSDScriptEvent::EVENT_LEAVE_FUNCTION)
  {
    // safe guard
    if(!m_pProfilingStack->IsEmpty())
    {
      uint64 uiStopTime = VGLGetTimer();
      VRSDProfilingSample* pSample = m_pProfilingStack->Pop();

      uint64 uiTimeTaken = uiStopTime - pSample->m_uiStartTime;

      // Store the profiling information
      UpdateProfilingInformation(pFileName, iLineDefined == -1 ? "(native)" : pFunctionName, iLineDefined, uiTimeTaken);

      V_SAFE_DELETE(pSample);
    }
  }
}
Esempio n. 2
0
int VFixStepSceneUpdateController::GetUpdateTickCount()
{
  uint64 iTimeNow = VGLGetTimer();
  const uint64 iTicksPerSec = VGLGetTimerResolution() / m_iTicksPerSecond;
  if (m_iLastUpdateTickCount==0)
    m_iLastUpdateTickCount = iTimeNow;

  VASSERT(m_iLastUpdateTickCount<=iTimeNow);

  int iCount = (int)((iTimeNow-m_iLastUpdateTickCount) / iTicksPerSec);
  m_iLastUpdateTickCount += iTicksPerSec*iCount;
  if (m_iMaxTickCount>0 && iCount>m_iMaxTickCount)
    return m_iMaxTickCount;
  return iCount;
}
Esempio n. 3
0
 /// \fn VRSDProfilingSample(const char* pFunctionName, const char* pFileName, int iLineDefined)
 ///
 /// \brief  Default Constructor. 
 ///
 /// \param [in] pFunctionName Name of the function. 
 /// \param [in] pFileName Filename of the file. 
 /// \param  iLineDefined  The line the function was defined in. 
 ///
 VRSDProfilingSample(const char* pFunctionName, const char* pFileName, int iLineDefined)
   : m_iLineDefined(iLineDefined), m_uiStartTime(VGLGetTimer()), m_FunctionName(pFunctionName), m_FileName(pFileName)
 {
 }
 /// \brief
 ///   Returns the elapsed time since the last call to GetDiff().
 inline float GetDiff()
 {
   float fDiff = float(VGLGetTimer() - m_uiLastTime) / float(VGLGetTimerResolution());
   m_uiLastTime = VGLGetTimer();
   return fDiff;
 }
 /// \brief
 ///   Returns the elapsed time since creation of the timer instance or the last call to reset.
 inline float GetTime() const
 {
   return float(VGLGetTimer() - m_uiStartTime) / float(VGLGetTimerResolution());
 }
 /// \brief
 ///   Resets the performance timer to the current time.
 inline void Reset()
 {
   m_uiStartTime = VGLGetTimer();
   m_uiLastTime = m_uiStartTime;
 }