当前位置: 首页>>代码示例>>C++>>正文


C++ PerformanceTimer::GetMilliseconds方法代码示例

本文整理汇总了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;
}
开发者ID:etnlGD,项目名称:renderdoc,代码行数:98,代码来源:amd_counters.cpp


注:本文中的PerformanceTimer::GetMilliseconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。