void muFrame::OnUpdatingProgress(UpdaterEvent& event) { if( event.GetExtraLong() > 0.0f ) m_updatingProgress = wxDouble(event.GetInt()) / wxDouble(event.GetExtraLong()); else m_updatingProgress = 0.0f; DisplayUpdatingProgress(); if( !event.GetString().IsEmpty() ) wxLogVerbose(wxT("[Updater] %s"), event.GetString().c_str()); if( m_updatingProgress > 0 ) { double dlnow = event.GetInt(); double dltotal = event.GetExtraLong(); static wxStopWatch eventWatch; static double lastdl = 0; double dldelta = dlnow - lastdl; dldelta /= 1024.0f; lastdl = dlnow; eventWatch.Pause(); double speed = 0; if( eventWatch.Time() > 0.0f ) speed = dldelta / eventWatch.Time(); eventWatch.Start(); static double speedAvg = 0.0f; if( speed >= 0.0f ) speedAvg = (speedAvg*0.95f + speed*0.05f); wxString remainingText = wxT("?"); if( speedAvg > 0 ) { double secondsRemaining = (dltotal-dlnow) / 1024.0f / (speedAvg * 1000.0f); wxTimeSpan span = wxTimeSpan::Seconds(secondsRemaining); remainingText = span.Format(); } // update label every second only static wxStopWatch limitWatch; limitWatch.Pause(); if( limitWatch.Time() > 1000 ) { m_detailsLabel->SetLabel(wxString::Format( wxT("Downloading Gunreal v%i... %s remaining (%03.1lf MB at %0.0lf KB/s)") , m_latestVersion , remainingText.c_str() , dltotal / 1024.0f / 1024.0f , speedAvg * 1000.0f )); limitWatch.Start(); } else limitWatch.Resume(); } }
int QSPCallBacks::GetMSCount() { static wxStopWatch stopWatch; int ret = stopWatch.Time(); stopWatch.Start(); return ret; }
void muFrame::OnUpdatingProgress(UpdaterEvent& event) { if( event.GetExtraLong() > 0.0f ) m_updatingProgress = wxDouble(event.GetInt()) / wxDouble(event.GetExtraLong()); else m_updatingProgress = 0.0f; DisplayUpdatingProgress(); if( !event.GetString().IsEmpty() ) wxLogVerbose(event.GetString()); if( m_updatingProgress > 0 ) { double dlnow = event.GetInt(); //double dltotal = event.GetExtraLong(); static wxStopWatch eventWatch; static double lastdl = 0; double dldelta = dlnow - lastdl; dldelta /= 1024; lastdl = dlnow; eventWatch.Pause(); double speed = 0; if( eventWatch.Time() > 0.0f ) speed = dldelta / eventWatch.Time() * 1000.0f; eventWatch.Start(); static double speedAvg = 0.0f; if( speed >= 0.0f ) speedAvg = (speedAvg*0.95f + speed*0.05f); // update label every second only static wxStopWatch limitWatch; limitWatch.Pause(); if( limitWatch.Time() > 1000 ) { m_detailsLabel->SetLabel(wxString::Format( wxT("Downloading Gunreal v%i - %0.1lf%% at %0.0lfKb/s...") , m_latestVersion, m_updatingProgress*100.0f, speedAvg)); limitWatch.Start(); } else limitWatch.Resume(); } }
void diagnostics_do_perfmon_start( t_diag_struct * pDiag, t_diag_struct ** pRememberMe ){ if( *pRememberMe == NULL ){ *pRememberMe = pDiag; if( !bStopWatchStarted ){ bStopWatchStarted = true; MasterWatch.Start(); } } pDiag->most_recent = MasterWatch.Time(); }
void diagnostics_do_perfmon_stop( t_diag_struct ** ppDiag ){ t_diag_struct * pDiag = *ppDiag; *ppDiag = NULL; long amount = MasterWatch.Time() - pDiag->most_recent; pDiag->total += amount; pDiag->most_recent = amount; if( pDiag->countdown == (pDiag->initial_count -1 )){ pDiag->most = amount; pDiag->least = amount; } else if( amount > pDiag->most ) pDiag->most = amount; else if( amount < pDiag->least ) pDiag->least = amount; wxLog * pLog = wxLog::SetActiveTarget(NULL); wxLogDebug( wxT("%s %f seconds"), pDiag->pMessage, ((float)amount)/1000.0f ); wxLog::SetActiveTarget(pLog); }
long int TakeTime(FILE *f , char *st){ long int delta=sw.Time(); fprintf(f,"%5ldmsec: %s\n",delta,st); //globaltime=timen; return delta; }
DWORD WINAPI GetTickCount(VOID) { static wxStopWatch sw; return sw.Time(); }