本文整理汇总了C++中PerformanceTimer::GetMilliseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ PerformanceTimer::GetMilliseconds方法的具体用法?C++ PerformanceTimer::GetMilliseconds怎么用?C++ PerformanceTimer::GetMilliseconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerformanceTimer
的用法示例。
在下文中一共展示了PerformanceTimer::GetMilliseconds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
std::vector<CounterResult> AMDCounters::GetCounterData(uint32_t sessionID, uint32_t maxSampleIndex,
const std::vector<uint32_t> &eventIDs,
const std::vector<GPUCounter> &counters)
{
std::vector<CounterResult> ret;
bool isReady = false;
const uint32_t timeoutPeriod = 10000; // ms
PerformanceTimer timeout;
do
{
isReady = IsSessionReady(sessionID);
if(!isReady)
{
Threading::Sleep(0);
PerformanceTimer endTime;
if(timeout.GetMilliseconds() > timeoutPeriod)
{
GPA_LoggingCallback(GPA_LOGGING_ERROR, "GetCounterData failed due to elapsed timeout.");
return ret;
}
}
} while(!isReady);
for(uint32_t s = 0; s < maxSampleIndex; s++)
{
for(size_t c = 0; c < counters.size(); c++)
{
const CounterDescription desc = GetCounterDescription(counters[c]);
switch(desc.resultType)
{
case CompType::UInt:
{
if(desc.resultByteWidth == sizeof(uint32_t))
{
uint32_t value = GetSampleUint32(sessionID, s, counters[c]);
if(desc.unit == CounterUnit::Percentage)
{
value = RDCCLAMP(value, 0U, 100U);
}
ret.push_back(CounterResult(eventIDs[s], counters[c], value));
}
else if(desc.resultByteWidth == sizeof(uint64_t))
{
uint64_t value = GetSampleUint64(sessionID, s, counters[c]);
if(desc.unit == CounterUnit::Percentage)
{
value = RDCCLAMP(value, (uint64_t)0, (uint64_t)100);
}
ret.push_back(CounterResult(eventIDs[s], counters[c], value));
}
else
{
RDCERR("Unexpected byte width %u", desc.resultByteWidth);
}
}
break;
case CompType::Float:
{
float value = GetSampleFloat32(sessionID, s, counters[c]);
if(desc.unit == CounterUnit::Percentage)
{
value = RDCCLAMP(value, 0.0f, 100.0f);
}
ret.push_back(CounterResult(eventIDs[s], counters[c], value));
}
break;
case CompType::Double:
{
double value = GetSampleFloat64(sessionID, s, counters[c]);
if(desc.unit == CounterUnit::Percentage)
{
value = RDCCLAMP(value, 0.0, 100.0);
}
ret.push_back(CounterResult(eventIDs[s], counters[c], value));
}
break;
default: RDCASSERT(0); break;
};
}
}
return ret;
}