本文整理汇总了C++中CElapsedTime::Reset方法的典型用法代码示例。如果您正苦于以下问题:C++ CElapsedTime::Reset方法的具体用法?C++ CElapsedTime::Reset怎么用?C++ CElapsedTime::Reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CElapsedTime
的用法示例。
在下文中一共展示了CElapsedTime::Reset方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoPulse
///////////////////////////////////////////////////////////////
//
// CPerfStatFunctionTimingImpl::DoPulse
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatFunctionTimingImpl::DoPulse ( void )
{
// Maybe turn off stats gathering if nobody is watching
if ( m_bIsActive && m_TimeSinceLastViewed.Get () > 15000 )
SetActive ( false );
// Do nothing if not active
if ( !m_bIsActive )
{
m_TimingMap.empty ();
return;
}
// Check if time to cycle the stats
if ( m_TimeSinceUpdate.Get () >= 5000 )
{
m_TimeSinceUpdate.Reset ();
// For each timed function
for ( std::map < SString, SFunctionTimingInfo >::iterator iter = m_TimingMap.begin () ; iter != m_TimingMap.end () ; )
{
SFunctionTimingInfo& item = iter->second;
// Update history
item.iPrevIndex = ( item.iPrevIndex + 1 ) % NUMELMS( item.history );
item.history[ item.iPrevIndex ] = item.now5s;
// Reset accumulator
item.now5s.uiNumCalls = 0;
item.now5s.fTotalMs = 0;
item.now5s.fPeakMs = 0;
// Recalculate last 60 second stats
item.prev60s.uiNumCalls = 0;
item.prev60s.fTotalMs = 0;
item.prev60s.fPeakMs = 0;
for ( uint i = 0 ; i < NUMELMS( item.history ) ; i++ )
{
const STiming& slot = item.history[i];
item.prev60s.uiNumCalls += slot.uiNumCalls;
item.prev60s.fTotalMs += slot.fTotalMs;
item.prev60s.fPeakMs = Max ( item.prev60s.fPeakMs, slot.fPeakMs );
}
// Remove from map if no calls in the last 60s
if ( item.prev60s.uiNumCalls == 0 )
m_TimingMap.erase ( iter++ );
else
++iter;
}
}
//
// Update PeakUs threshold
//
m_PeakUsRequiredHistory.RemoveOlderThan ( 10000 );
m_PeakUsThresh = m_PeakUsRequiredHistory.GetLowestValue ( DEFAULT_THRESH_MS * 1000 );
}
示例2: Draw
///////////////////////////////////////////////////////////////
//
// CMemStats::Draw
//
//
//
///////////////////////////////////////////////////////////////
void CMemStats::Draw ( void )
{
if ( !m_bEnabled )
return;
UpdateFrameStats ();
// Time to update?
if ( m_UpdateTimer.Get () > 2000 )
{
m_UpdateTimer.Reset ();
UpdateIntervalStats ();
CreateTables ();
}
float fResWidth = static_cast < float > ( g_pGraphics->GetViewportWidth () );
float fResHeight = static_cast < float > ( g_pGraphics->GetViewportHeight () );
float fTotalHeight = 0;
// Draw tables
if ( !m_TableList.empty () )
{
float fX = fResWidth - m_TableList.front ().GetPixelWidth () - 15;
float fY = 200 - m_fPosY;
for ( std::list < CDxTable >::iterator iter = m_TableList.begin () ; iter != m_TableList.end () ; ++iter )
{
CDxTable& table = *iter;
table.Draw ( fX, fY, 0x78000000, 10, 10, 8, 8 );
float fHeight = table.GetPixelHeight () + 20;
fY += fHeight;
fTotalHeight += fHeight;
}
}
// Handle scrolling
bool bHoldingPageUp = ( GetAsyncKeyState ( VK_PRIOR ) & 0x8000 ) != 0;
bool bHoldingPageDown = ( GetAsyncKeyState ( VK_NEXT ) & 0x8000 ) != 0;
if ( bHoldingPageUp )
{
m_fPosY = std::max ( 0.f, m_fPosY - 10 );
}
if ( bHoldingPageDown )
{
float fScrollHeight = fTotalHeight - ( fResHeight - 200 );
if ( fScrollHeight > 0 )
m_fPosY = std::min ( fScrollHeight, m_fPosY + 10 );
}
}
示例3: GetStats
///////////////////////////////////////////////////////////////
//
// CPerfStatEventPacketUsageImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatEventPacketUsageImpl::GetStats ( CPerfStatResult* pResult, const std::map < SString, int >& strOptionMap, const SString& strFilter )
{
m_TimeSinceGetStats.Reset ();
m_bEnabled = true;
MaybeRecordStats();
//
// Set option flags
//
bool bHelp = MapContains ( strOptionMap, "h" );
//
// Process help
//
if ( bHelp )
{
pResult->AddColumn ( "Event Packet usage help" );
pResult->AddRow ()[0] ="Option h - This help";
return;
}
// Add columns
pResult->AddColumn ( "Type" );
pResult->AddColumn ( "Name" );
pResult->AddColumn ( "msgs/sec" );
pResult->AddColumn ( "5 sec.msgs" );
// Fill rows
for ( uint i = 0 ; i < m_EventUsageSortedList.size() && i < 30 ; i++ )
{
const SEventUsage& usage = m_EventUsageSortedList[i];
// Add row
SString* row = pResult->AddRow ();
SString strType;
if ( usage.iEventOut )
strType += "Event ";
if ( usage.iElementDataOut )
strType += "ElementData ";
if ( usage.iElementDataRelay )
strType += "ElementData(Relay) ";
int c = 0;
row[c++] = strType;
row[c++] = usage.strName;
row[c++] = SString ( "%d", ( usage.iTotal + 4 ) / 5 );
row[c++] = SString ( "%d", usage.iTotal );
}
}
示例4: UpdateDebugData
///////////////////////////////////////////////////////////////
//
// CDatabaseJobQueueImpl::UpdateDebugData
//
// Update info relevant to debugging database jobs
//
///////////////////////////////////////////////////////////////
void CDatabaseJobQueueImpl::UpdateDebugData ( void )
{
// Update once every 10 seconds
if ( m_JobCountElpasedTime.Get () < 10000 )
return;
shared.m_Mutex.Lock ();
// Log to console if connection count is creeping up
if ( shared.m_HandleConnectionMap.size() > m_uiConnectionCountWarnThresh )
{
m_uiConnectionCountWarnThresh = shared.m_HandleConnectionMap.size() * 2;
CLogger::LogPrintf( "Notice: There are now %d database connections\n", shared.m_HandleConnectionMap.size() );
}
// Log to console if job count is creeping up
m_uiJobCount10sMin = std::min < uint > ( m_uiJobCount10sMin, m_ActiveJobHandles.size () );
if ( m_uiJobCount10sMin > m_uiJobCountWarnThresh )
{
m_uiJobCountWarnThresh = m_uiJobCount10sMin * 2;
CLogger::LogPrintf ( "Notice: %d database query handles active in the last 10 seconds\n", m_uiJobCount10sMin );
}
m_JobCountElpasedTime.Reset ();
m_uiJobCount10sMin = m_ActiveJobHandles.size ();
CTickCount timeNow = CTickCount::Now ( true );
// Log old uncollected queries
for ( CJobQueueType::iterator iter = shared.m_ResultQueue.begin () ; iter != shared.m_ResultQueue.end () ; iter++ )
{
CDbJobData* pJobData = *iter;
if ( !pJobData->result.bLoggedWarning )
{
CTickCount age = timeNow - pJobData->result.timeReady;
if ( age.ToLongLong () > 1000 * 60 * 5 )
{
shared.m_Mutex.Unlock ();
g_pGame->GetScriptDebugging()->LogWarning( pJobData->m_LuaDebugInfo, "Database result uncollected after 5 minutes. [Query: %s]", *pJobData->GetCommandStringForLog() );
shared.m_Mutex.Lock ();
pJobData->result.bLoggedWarning = true;
break;
}
}
}
shared.m_Mutex.Unlock ();
}
示例5: MaybeTidyUp
////////////////////////////////////////////////////////////////
//
// CEffectClonerImpl::MaybeTidyUp
//
// Tidy up if been a little while since last time
//
////////////////////////////////////////////////////////////////
void CEffectClonerImpl::MaybeTidyUp ( bool bForceDrasticMeasures, CEffectTemplate* pKeepThis )
{
if ( !bForceDrasticMeasures && m_TidyupTimer.Get () < 1000 )
return;
m_TidyupTimer.Reset ();
// Everything in Old List can go if not being used
for ( uint i = 0 ; i < m_OldList.size () ; i++ )
{
CEffectTemplate* pEffectTemplate = m_OldList[i];
if ( pEffectTemplate != pKeepThis && pEffectTemplate->GetTicksSinceLastUsed () > ( bForceDrasticMeasures ? 0 : 1 ) )
{
OutputDebugLine ( "[Shader] CEffectClonerImpl::MaybeTidyUp: Releasing old EffectTemplate" );
SAFE_RELEASE( pEffectTemplate );
ListRemoveIndex ( m_OldList, i-- );
}
}
// Complex calculation to guess how long to leave an effect unused before deleting
// 0=30 mins 100=25 mins 200=16 mins 300=1 sec
float fTicksAlpha = UnlerpClamped ( 0, m_ValidMap.size (), 300 );
int iTicks = static_cast < int > ( ( 1 - fTicksAlpha * fTicksAlpha ) * 30 * 60 * 1000 ) + 1000;
#ifdef MTA_DEBUG
iTicks /= 60; // Mins to seconds for debug
#endif
// Valid Effect not used for a little while can go
for ( std::map < SString, CEffectTemplate* >::iterator iter = m_ValidMap.begin () ; iter != m_ValidMap.end () ; )
{
CEffectTemplate* pEffectTemplate = iter->second;
if ( pEffectTemplate != pKeepThis && pEffectTemplate->GetTicksSinceLastUsed () > ( bForceDrasticMeasures ? 0 : iTicks ) )
{
OutputDebugLine ( "[Shader] CEffectClonerImpl::MaybeTidyUp: Releasing valid EffectTemplate" );
SAFE_RELEASE( pEffectTemplate );
m_ValidMap.erase ( iter++ );
}
else
++iter;
}
if ( bForceDrasticMeasures )
{
CGraphics::GetSingleton().GetDevice()->EvictManagedResources();
}
}
示例6: HelperGetToucanDLL
static HMODULE HelperGetToucanDLL()
{
if (g_toucan_dll)
return g_toucan_dll;
// Only scan once every five seconds
if ( g_NextToucanDLLSearchTime.Get () < 5000 )
return NULL;
g_NextToucanDLLSearchTime.SetMaxIncrement ( 500, true );
g_NextToucanDLLSearchTime.Reset ();
/*
** We need to enumerate the DLLs loaded to find toucan dll.
** This is done because the toucan dll changes with each update.
** The toucan dll has the following format. "xfire_toucan_{BUILD_NUMBER}.dll"
** We simply try to find a dll w/ the prefix "xfire_toucan"
*/
HANDLE snapshot_handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
if (snapshot_handle != INVALID_HANDLE_VALUE)
{
MODULEENTRY32 module_entry;
module_entry.dwSize = sizeof(MODULEENTRY32);
BOOL result = Module32First(snapshot_handle, &module_entry);
char module_name[] = "xfire_toucan";
DWORD module_name_len = sizeof(module_name)-1;
while (result)
{
if (CompareStringA(LOCALE_USER_DEFAULT, NORM_IGNORECASE, module_entry.szModule, module_name_len, module_name, module_name_len) == CSTR_EQUAL)
{
g_toucan_dll = module_entry.hModule;
break;
}
result = Module32Next(snapshot_handle, &module_entry);
}
CloseHandle(snapshot_handle);
}
return g_toucan_dll;
}
示例7: DoPulse
///////////////////////////////////////////////////////////////
//
// CPerfStatDebugTableImpl::DoPulse
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatDebugTableImpl::DoPulse ( void )
{
// Do remove old once every second
if ( m_TimeSinceRemoveOld.Get () < 1000 )
return;
m_TimeSinceRemoveOld.Reset ();
LOCK_SCOPE ( m_CS );
CTickCount nowTickCount = CTickCount::Now ( true );
// Remove old
for ( std::map < SString, SLineInfo >::iterator iter = m_LineMap.begin () ; iter != m_LineMap.end () ; )
{
SLineInfo& info = iter->second;
if ( info.bHasEndTime && info.endTickCount < nowTickCount )
m_LineMap.erase ( iter++ );
else
++iter;
}
}
示例8: Load
bool CAccountManager::Load( void )
{
//Create a registry result
CRegistryResult result;
//Select all our required information from the accounts database
m_pDatabaseManager->QueryWithResultf ( m_hDbConnection, &result, "SELECT id,name,password,ip,serial,httppass from accounts" );
//Initialize all our variables
m_iAccounts = 0;
bool bNeedsVacuum = false;
CElapsedTime activityTimer;
bool bOutputFeedback = false;
for ( CRegistryResultIterator iter = result->begin() ; iter != result->end() ; ++iter )
{
const CRegistryResultRow& row = *iter;
//Fill User ID, Name & Password (Required data)
int iUserID = static_cast < int > ( row[0].nVal );
SString strName = (const char *)row[1].pVal;
SString strPassword = (const char *)row[2].pVal;
SString strIP = (const char *)row[3].pVal;
SString strSerial = (const char *)row[4].pVal;
SString strHttpPassAppend = (const char *)row[5].pVal;
// Check for overlong names and incorrect escapement
bool bRemoveAccount = false;
bool bChanged = false;
if ( strName.length () > 64 )
{
// Try to repair name
if ( strName.length () <= 256 )
{
strName = strName.Replace ( "\"\"", "\"", true ).substr ( 0, 64 );
bChanged = true;
}
// If name gone doolally or account with this name already exists, remove account
if ( strName.length () > 256 || Get ( strName ) )
{
bNeedsVacuum = true;
bRemoveAccount = true;
CLogger::LogPrintf ( "Removed duplicate or damaged account for %s\n", strName.substr ( 0, 64 ).c_str() );
}
}
// Check for disallowed account names
if ( strName == "*****" || strName == CONSOLE_ACCOUNT_NAME )
bRemoveAccount = true;
// Do account remove if required
if ( bRemoveAccount )
{
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM accounts WHERE id=?", SQLITE_INTEGER, iUserID );
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM userdata WHERE userid=?", SQLITE_INTEGER, iUserID );
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM serialusage WHERE userid=?", SQLITE_INTEGER, iUserID );
continue;
}
//Create a new account with the specified information
CAccount* pAccount = g_pGame->GetAccountManager ()->AddPlayerAccount ( strName, strPassword, iUserID, strIP, strSerial, strHttpPassAppend );
if ( bChanged )
pAccount->SetChanged ( bChanged );
m_iAccounts = std::max ( m_iAccounts, iUserID );
// Feedback for the user
if ( activityTimer.Get() > 5000 )
{
activityTimer.Reset();
bOutputFeedback = true;
CLogger::LogPrintf ( "Reading accounts %d/%d\n", m_List.size(), result->nRows );
}
}
if ( bOutputFeedback )
CLogger::LogPrintf ( "Reading accounts done.\n");
if ( bNeedsVacuum )
m_pDatabaseManager->Execf ( m_hDbConnection, "VACUUM" );
// Save any upgraded accounts
{
CElapsedTime activityTimer;
bool bOutputFeedback = false;
uint uiSaveCount = 0;
for ( CMappedAccountList::const_iterator iter = m_List.begin () ; iter != m_List.end () ; iter++ )
{
CAccount* pAccount = *iter;
if ( pAccount->IsRegistered () && pAccount->HasChanged () && !pAccount->IsConsoleAccount () )
{
uiSaveCount++;
Save ( pAccount, false );
// Feedback for the user
if ( activityTimer.Get() > 5000 )
{
activityTimer.Reset();
bOutputFeedback = true;
CLogger::LogPrintf ( "Saving upgraded accounts %d\n", uiSaveCount );
}
}
}
if ( uiSaveCount > 100 )
//.........这里部分代码省略.........
示例9: GetStats
///////////////////////////////////////////////////////////////
//
// CPerfStatRPCPacketUsageImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatRPCPacketUsageImpl::GetStats(CPerfStatResult* pResult, const std::map<SString, int>& strOptionMap, const SString& strFilter)
{
m_TimeSinceGetStats.Reset();
MaybeRecordStats();
//
// Set option flags
//
bool bHelp = MapContains(strOptionMap, "h");
//
// Process help
//
if (bHelp)
{
pResult->AddColumn("RPC Packet usage help");
pResult->AddRow()[0] = "Option h - This help";
return;
}
// Add columns
pResult->AddColumn("Packet type");
pResult->AddColumn("Incoming.msgs/sec");
pResult->AddColumn("Incoming.bytes/sec");
pResult->AddColumn("Incoming.cpu");
pResult->AddColumn("Outgoing.msgs/sec");
pResult->AddColumn("Outgoing.bytes/sec");
pResult->AddColumn("Outgoing.cpu");
if (m_iStatsCleared)
{
pResult->AddRow()[0] = "Sampling... Please wait";
}
long long llTickCountNow = CTickCount::Now().ToLongLong();
// Fill rows
for (uint i = 0; i < 256; i++)
{
// Calc incoming delta values
SPacketStat statInDelta;
{
const SRPCPacketStat& statInPrev = m_PrevPacketStatsIn[i];
const SRPCPacketStat& statInNow = m_PacketStatsIn[i];
statInDelta.iCount = statInNow.iCount - statInPrev.iCount;
statInDelta.iTotalBytes = statInNow.iTotalBytes - statInPrev.iTotalBytes;
// statInDelta.totalTime = statInNow.totalTime - statInPrev.totalTime;
}
if (!statInDelta.iCount)
{
// Once displayed, keep a row displayed for at least 20 seconds
if (llTickCountNow - m_ShownPacketStatsIn[i] > 20000)
continue;
}
else
{
m_ShownPacketStatsIn[i] = llTickCountNow;
}
// Add row
SString* row = pResult->AddRow();
int c = 0;
// Turn "CRPCFunctions::PLAYER_WEAPON" into "64_Player_weapon"
SString strPacketDesc = EnumToString((CRPCFunctions::eRPCFunctions)i).SplitRight("CRPCFunctions::", NULL, -1).ToLower();
row[c++] = SString("%d_", i) + strPacketDesc.Left(1).ToUpper() + strPacketDesc.SubStr(1);
if (statInDelta.iCount)
{
row[c++] = SString("%d", (statInDelta.iCount + 4) / 5);
row[c++] = CPerfStatManager::GetScaledByteString((statInDelta.iTotalBytes + 4) / 5);
row[c++] = "n/a";
}
else
{
row[c++] = "-";
row[c++] = "-";
row[c++] = "-";
}
row[c++] = "-";
row[c++] = "-";
row[c++] = "-";
}
// Fill rows
for (uint i = 0; i < 256; i++)
{
// Calc outgoing delta values
SRPCPacketStat statOutDelta;
{
const SRPCPacketStat& statOutPrev = m_PrevPacketStatsOut[i];
//.........这里部分代码省略.........
示例10: GetStats
///////////////////////////////////////////////////////////////
//
// CPerfStatPacketUsageImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatPacketUsageImpl::GetStats(CPerfStatResult* pResult, const std::map<SString, int>& strOptionMap, const SString& strFilter)
{
m_TimeSinceGetStats.Reset();
MaybeRecordStats();
//
// Set option flags
//
bool bHelp = MapContains(strOptionMap, "h");
//
// Process help
//
if (bHelp)
{
pResult->AddColumn("Packet usage help");
pResult->AddRow()[0] = "Option h - This help";
return;
}
// Add columns
pResult->AddColumn("Packet type");
pResult->AddColumn("Incoming.msgs/sec");
pResult->AddColumn("Incoming.bytes/sec");
pResult->AddColumn("Incoming.logic cpu");
pResult->AddColumn("Outgoing.msgs/sec");
pResult->AddColumn("Outgoing.bytes/sec");
pResult->AddColumn("Outgoing.msgs share");
if (m_iStatsCleared)
{
pResult->AddRow()[0] = "Sampling... Please wait";
}
// Calc msgs grand total for percent calculation
int iOutDeltaCountTotal = 0;
for (uint i = 0; i < 256; i++)
{
const SPacketStat& statOutPrev = m_PrevPacketStats[CNetServer::STATS_OUTGOING_TRAFFIC][i];
const SPacketStat& statOutNow = m_PacketStats[CNetServer::STATS_OUTGOING_TRAFFIC][i];
iOutDeltaCountTotal += statOutNow.iCount - statOutPrev.iCount;
}
long long llTickCountNow = CTickCount::Now().ToLongLong();
// Fill rows
for (uint i = 0; i < 256; i++)
{
// Calc incoming delta values
SPacketStat statInDelta;
{
const SPacketStat& statInPrev = m_PrevPacketStats[CNetServer::STATS_INCOMING_TRAFFIC][i];
const SPacketStat& statInNow = m_PacketStats[CNetServer::STATS_INCOMING_TRAFFIC][i];
statInDelta.iCount = statInNow.iCount - statInPrev.iCount;
statInDelta.iTotalBytes = statInNow.iTotalBytes - statInPrev.iTotalBytes;
statInDelta.totalTime = statInNow.totalTime - statInPrev.totalTime;
}
// Calc outgoing delta values
SPacketStat statOutDelta;
{
const SPacketStat& statOutPrev = m_PrevPacketStats[CNetServer::STATS_OUTGOING_TRAFFIC][i];
const SPacketStat& statOutNow = m_PacketStats[CNetServer::STATS_OUTGOING_TRAFFIC][i];
statOutDelta.iCount = statOutNow.iCount - statOutPrev.iCount;
statOutDelta.iTotalBytes = statOutNow.iTotalBytes - statOutPrev.iTotalBytes;
statOutDelta.totalTime = statOutNow.totalTime - statOutPrev.totalTime;
}
if (!statInDelta.iCount && !statOutDelta.iCount)
{
// Once displayed, keep a row displayed for at least 20 seconds
if (llTickCountNow - m_ShownPacketStats[i] > 20000)
continue;
}
else
{
m_ShownPacketStats[i] = llTickCountNow;
}
// Add row
SString* row = pResult->AddRow();
int c = 0;
// Turn "PACKET_ID_PED_SYNC" into "64_Ped_sync"
SString strPacketDesc = EnumToString((ePacketID)i).SplitRight("PACKET_ID", NULL, -1).ToLower();
row[c++] = SString("%d", i) + strPacketDesc.Left(2).ToUpper() + strPacketDesc.SubStr(2);
if (statInDelta.iCount)
{
row[c++] = SString("%d", (statInDelta.iCount + 4) / 5);
row[c++] = CPerfStatManager::GetScaledByteString((statInDelta.iTotalBytes + 4) / 5);
row[c++] = SString("%2.2f%%",
statInDelta.totalTime / 50000.f); // Number of microseconds in sample period ( 5sec * 1000000 ) into percent ( * 100 )
}
else
//.........这里部分代码省略.........
示例11: GetStats
//.........这里部分代码省略.........
if ( pConfig->GetThreadNetEnabled () )
{
m_StatusList.push_back ( StringPair ( "Msg queue incoming", SString ( "%d", CNetBufferWatchDog::ms_uiInResultQueueSize ) ) );
if ( bIncludeDebugInfo )
m_StatusList.push_back ( StringPair ( " finished incoming", SString ( "%d", CNetBufferWatchDog::ms_uiFinishedListSize ) ) );
m_StatusList.push_back ( StringPair ( "Msg queue outgoing", SString ( "%d", CNetBufferWatchDog::ms_uiOutCommandQueueSize ) ) );
if ( bIncludeDebugInfo )
m_StatusList.push_back ( StringPair ( " finished outgoing", SString ( "%d", CNetBufferWatchDog::ms_uiOutResultQueueSize ) ) );
}
if ( ASE* pAse = ASE::GetInstance() )
m_StatusList.push_back ( StringPair ( "ASE queries", SString ( "%d (%d/min)", pAse->GetTotalQueryCount (), pAse->GetQueriesPerMinute () ) ) );
m_OptionsList.push_back ( StringPair ( "MinClientVersion", g_pGame->CalculateMinClientRequirement () ) );
m_OptionsList.push_back ( StringPair ( "RecommendedClientVersion", pConfig->GetRecommendedClientVersion () ) );
m_OptionsList.push_back ( StringPair ( "NetworkEncryptionEnabled", SString ( "%d", pConfig->GetNetworkEncryptionEnabled () ) ) );
m_OptionsList.push_back ( StringPair ( "VoiceEnabled", SString ( "%d", pConfig->IsVoiceEnabled () ) ) );
m_OptionsList.push_back ( StringPair ( "Busy sleep time", SString ( "%d ms", pConfig->GetPendingWorkToDoSleepTime () ) ) );
m_OptionsList.push_back ( StringPair ( "Idle sleep time", SString ( "%d ms", pConfig->GetNoWorkToDoSleepTime () ) ) );
m_OptionsList.push_back ( StringPair ( "BandwidthReductionMode", pConfig->GetSetting ( "bandwidth_reduction" ) ) );
m_OptionsList.push_back ( StringPair ( "LightSyncEnabled", SString ( "%d", g_pBandwidthSettings->bLightSyncEnabled ) ) );
m_OptionsList.push_back ( StringPair ( "ThreadNetEnabled", SString ( "%d", pConfig->GetThreadNetEnabled () ) ) );
const static CTickRateSettings defaultRates;
if ( defaultRates.iPureSync != g_TickRateSettings.iPureSync )
m_OptionsList.push_back ( StringPair ( "Player sync interval", SString ( "%d", g_TickRateSettings.iPureSync ) ) );
if ( defaultRates.iLightSync != g_TickRateSettings.iLightSync )
m_OptionsList.push_back ( StringPair ( "Lightweight sync interval", SString ( "%d", g_TickRateSettings.iLightSync ) ) );
if ( defaultRates.iCamSync != g_TickRateSettings.iCamSync )
m_OptionsList.push_back ( StringPair ( "Camera sync interval", SString ( "%d", g_TickRateSettings.iCamSync ) ) );
if ( defaultRates.iPedSync != g_TickRateSettings.iPedSync )
m_OptionsList.push_back ( StringPair ( "Ped sync interval", SString ( "%d", g_TickRateSettings.iPedSync ) ) );
if ( defaultRates.iUnoccupiedVehicle != g_TickRateSettings.iUnoccupiedVehicle )
m_OptionsList.push_back ( StringPair ( "Unocc. veh. sync interval", SString ( "%d", g_TickRateSettings.iUnoccupiedVehicle ) ) );
if ( defaultRates.iKeySyncRotation != g_TickRateSettings.iKeySyncRotation )
m_OptionsList.push_back ( StringPair ( "Keysync mouse sync interval", SString ( "%d", g_TickRateSettings.iKeySyncRotation ) ) );
if ( defaultRates.iKeySyncAnalogMove != g_TickRateSettings.iKeySyncAnalogMove )
m_OptionsList.push_back ( StringPair ( "Keysync analog sync interval", SString ( "%d", g_TickRateSettings.iKeySyncAnalogMove ) ) );
if ( defaultRates.iKeySyncAnalogMove != g_TickRateSettings.iNearListUpdate )
m_OptionsList.push_back ( StringPair ( "Update near interval", SString ( "%d", g_TickRateSettings.iNearListUpdate ) ) );
if ( bIncludeDebugInfo )
{
m_StatusList.push_back ( StringPair ( "Bytes/sec outgoing resent", CPerfStatManager::GetScaledByteString ( llOutgoingBytesResentPS ) ) );
m_StatusList.push_back ( StringPair ( "Msgs/sec outgoing resent", strOutgoingMessagesResentPS ) );
m_StatusList.push_back ( StringPair ( "Bytes/sec blocked", CPerfStatManager::GetScaledByteString ( llIncomingBytesPSBlocked ) ) );
m_StatusList.push_back ( StringPair ( "Packets/sec blocked", strIncomingPacketsPSBlocked ) );
m_StatusList.push_back ( StringPair ( "Usage incl. blocked", CPerfStatManager::GetScaledBitString ( llNetworkUsageBytesPSInclBlocked * 8LL ) + "/s" ) );
m_OptionsList.push_back ( StringPair ( "Main (Logic) core #", SString ( "%d", _GetCurrentProcessorNumber () ) ) );
m_OptionsList.push_back ( StringPair ( "Threadnet (Sync) core #", SString ( "%d", g_uiThreadnetProcessorNumber ) ) );
m_OptionsList.push_back ( StringPair ( "Raknet thread core #", SString ( "%d", m_PrevLiveStats.uiNetworkUpdateLoopProcessorNumber ) ) );
m_OptionsList.push_back ( StringPair ( "DB thread core #", SString ( "%d", g_uiDatabaseThreadProcessorNumber ) ) );
// Get net performance stats
if ( m_NetPerformanceStatsUpdateTimer.Get() > 2000 )
{
m_NetPerformanceStatsUpdateTimer.Reset();
g_pNetServer->GetNetPerformanceStatistics ( &m_NetPerformanceStats, true );
}
m_OptionsList.push_back ( StringPair ( "Update cycle prep time max", SString ( "%s ms (Avg %s ms)", *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.uiUpdateCyclePrepTimeMaxUs / 1000.f ), *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.uiUpdateCyclePrepTimeAvgUs / 1000.f ) ) ) );
m_OptionsList.push_back ( StringPair ( "Update cycle process time max", SString ( "%s ms (Avg %s ms)", *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.uiUpdateCycleProcessTimeMaxUs / 1000.f ), *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.uiUpdateCycleProcessTimeAvgUs / 1000.f ) ) ) );
m_OptionsList.push_back ( StringPair ( "Update cycle datagrams max", SString ( "%d (Avg %s)", m_NetPerformanceStats.uiUpdateCycleDatagramsMax, *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.fUpdateCycleDatagramsAvg ) ) ) );
m_OptionsList.push_back ( StringPair ( "Update cycle datagrams limit", SString ( "%d", m_NetPerformanceStats.uiUpdateCycleDatagramsLimit ) ) );
m_OptionsList.push_back ( StringPair ( "Update cycle sends limited", SString ( "%d (%s %%)", m_NetPerformanceStats.uiUpdateCycleSendsLimitedTotal, *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.fUpdateCycleSendsLimitedPercent ) ) ) );
}
// Add columns
pResult->AddColumn ( "Info.Name" );
pResult->AddColumn ( "Info.Value" );
pResult->AddColumn ( "Status.Name" );
pResult->AddColumn ( "Status.Value" );
pResult->AddColumn ( "Settings.Name" );
pResult->AddColumn ( "Settings.Value" );
// Output rows
std::vector < StringPair >* columnList[] = { &m_InfoList, &m_StatusList, &m_OptionsList };
uint uiMaxRows = Max ( Max ( m_InfoList.size (), m_StatusList.size () ), m_OptionsList.size () );
for ( uint i = 0 ; i < uiMaxRows ; i++ )
{
SString* row = pResult->AddRow ();
int c = 0;
for ( uint a = 0 ; a < NUMELMS( columnList ) ; a++ )
{
const std::vector < StringPair >& column = *columnList[a];
if ( i < column.size () )
{
row[c++] = column[i].strName;
row[c++] = column[i].strValue;
}
else
{
row[c++] = "";
row[c++] = "";
}
}
}
}
示例12: GetStats
///////////////////////////////////////////////////////////////
//
// CPerfStatFunctionTimingImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatFunctionTimingImpl::GetStats ( CPerfStatResult* pResult, const std::map < SString, int >& optionMap, const SString& strFilter )
{
m_TimeSinceLastViewed.Reset ();
SetActive ( true );
//
// Set option flags
//
bool bHelp = MapContains ( optionMap, "h" );
uint uiPeakBytesThresh = 1000;
int iPeakMsThresh = optionMap.empty () ? -1 : atoi ( optionMap.begin ()->first );
if ( iPeakMsThresh < 0 )
iPeakMsThresh = DEFAULT_THRESH_MS;
m_PeakUsRequiredHistory.AddValue ( iPeakMsThresh * 1000 );
//
// Process help
//
if ( bHelp )
{
pResult->AddColumn ( "Function timings help" );
pResult->AddRow ()[0] = "Option h - This help";
pResult->AddRow ()[0] = "0-50 - Peak Ms threshold (defaults to 1)";
return;
}
//
// Set column names
//
pResult->AddColumn ( " " );
pResult->AddColumn ( "10 sec.calls" );
pResult->AddColumn ( "10 sec.cpu total" );
pResult->AddColumn ( "10 sec.cpu peak" );
pResult->AddColumn ( "10 sec.cpu biggest call" );
pResult->AddColumn ( "10 sec.BW" );
//pResult->AddColumn ( "10 sec.BW peak" );
pResult->AddColumn ( "10 sec.BW biggest call" );
pResult->AddColumn ( "120 sec.calls" );
pResult->AddColumn ( "120 sec.cpu total" );
pResult->AddColumn ( "120 sec.cpu peak" );
pResult->AddColumn ( "120 sec.cpu biggest call" );
pResult->AddColumn ( "120 sec.BW" );
//pResult->AddColumn ( "120 sec.BW peak" );
pResult->AddColumn ( "120 sec.BW biggest call" );
//
// Set rows
//
for ( std::map < SString, SFunctionTimingInfo > :: const_iterator iter = m_TimingMap.begin () ; iter != m_TimingMap.end () ; iter++ )
{
const SString& strFunctionName = iter->first;
const SFunctionTimingInfo& item = iter->second;
const STiming& prev5s = item.history[ item.iPrevIndex ];
const STiming& prev60s = item.prev60s;
bool bHas5s = prev5s.uiNumCalls > 0;
bool bHas60s = prev60s.uiNumCalls > 0;
if ( !bHas5s && !bHas60s )
continue;
// Filter peak threshold for this viewer
if ( prev5s.fPeakMs < iPeakMsThresh && prev60s.fPeakMs < iPeakMsThresh &&
prev5s.uiPeakBytes < uiPeakBytesThresh && prev60s.uiPeakBytes < uiPeakBytesThresh )
continue;
// Apply filter
if ( strFilter != "" && strFunctionName.find ( strFilter ) == SString::npos )
continue;
// Add row
SString* row = pResult->AddRow ();
int c = 0;
row[c++] = strFunctionName;
if ( !bHas5s )
{
row[c++] = "-";
row[c++] = "-";
row[c++] = "-";
row[c++] = "-";
row[c++] = "";
//row[c++] = "";
row[c++] = "";
}
else
{
//.........这里部分代码省略.........
示例13: GetStats
///////////////////////////////////////////////////////////////
//
// CClientPerfStatPacketUsageImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CClientPerfStatPacketUsageImpl::GetStats ( CClientPerfStatResult* pResult, const std::map < SString, int >& strOptionMap, const SString& strFilter )
{
m_TimeSinceGetStats.Reset ();
//
// Set option flags
//
bool bHelp = MapContains ( strOptionMap, "h" );
//
// Process help
//
if ( bHelp )
{
pResult->AddColumn ( "Packet usage help" );
pResult->AddRow ()[0] ="Option h - This help";
return;
}
// Add columns
pResult->AddColumn ( "Packet type" );
pResult->AddColumn ( "Incoming.pkt/sec" );
pResult->AddColumn ( "Incoming.bytes/sec" );
pResult->AddColumn ( "Incoming.cpu" );
pResult->AddColumn ( "Outgoing.pkt/sec" );
pResult->AddColumn ( "Outgoing.bytes/sec" );
pResult->AddColumn ( "Outgoing.cpu" );
// Fill rows
for ( uint i = 0 ; i < 256 ; i++ )
{
// Calc incoming delta values
SPacketStat statInDelta;
{
const SPacketStat& statInPrev = m_PrevPacketStats [ CNet::STATS_INCOMING_TRAFFIC ] [ i ];
const SPacketStat& statInNow = m_PacketStats [ CNet::STATS_INCOMING_TRAFFIC ] [ i ];
statInDelta.iCount = statInNow.iCount - statInPrev.iCount;
statInDelta.iTotalBytes = statInNow.iTotalBytes - statInPrev.iTotalBytes;
statInDelta.totalTime = statInNow.totalTime - statInPrev.totalTime;
}
// Calc outgoing delta values
SPacketStat statOutDelta;
{
const SPacketStat& statOutPrev = m_PrevPacketStats [ CNet::STATS_OUTGOING_TRAFFIC ] [ i ];
const SPacketStat& statOutNow = m_PacketStats [ CNet::STATS_OUTGOING_TRAFFIC ] [ i ];
statOutDelta.iCount = statOutNow.iCount - statOutPrev.iCount;
statOutDelta.iTotalBytes = statOutNow.iTotalBytes - statOutPrev.iTotalBytes;
statOutDelta.totalTime = statOutNow.totalTime - statOutPrev.totalTime;
}
if ( !statInDelta.iCount && !statOutDelta.iCount )
continue;
// Add row
SString* row = pResult->AddRow ();
int c = 0;
// Turn "PACKET_ID_PED_SYNC" into "64_Ped_sync"
SString strPacketDesc = EnumToString ( (ePacketID)i ).SplitRight ( "PACKET_ID", NULL, -1 ).ToLower ();
row[c++] = SString ( "%d", i ) + strPacketDesc.Left ( 2 ).ToUpper () + strPacketDesc.SubStr ( 2 );
if ( statInDelta.iCount )
{
row[c++] = SString ( "%d", statInDelta.iCount / 5 );
row[c++] = SString ( "%d", statInDelta.iTotalBytes / 5 );
row[c++] = SString ( "%2.2f%%", statInDelta.totalTime / 50000.f ); // Number of microseconds in sample period ( 5sec * 1000000 ) into percent ( * 100 )
}
else
{
row[c++] = "-";
row[c++] = "-";
row[c++] = "-";
}
if ( statOutDelta.iCount )
{
row[c++] = SString ( "%d", statOutDelta.iCount / 5 );
row[c++] = SString ( "%d", statOutDelta.iTotalBytes / 5 );
//row[c++] = SString ( "%2.2f%%", statOutDelta.totalTime / 50000.f );
row[c++] = "n/a";
}
else
{
row[c++] = "-";
row[c++] = "-";
row[c++] = "-";
}
}
}