Beispiel #1
0
int64_t Timer::measure() const {
    if (m_type == WallTime) {
        return GetCurrentTimeMicros();
    }

    return GetRusageMicros(m_type, Timer::Self);
}
Beispiel #2
0
int64_t Timer::measure() const {
  if (m_type == WallTime) {
    return GetCurrentTimeMicros();
  }

  struct rusage ru;
  memset(&ru, 0, sizeof(ru));
  getrusage(RUSAGE_SELF, &ru);

  switch (m_type) {
  case SystemCPU: return to_usec(ru.ru_stime);
  case UserCPU:   return to_usec(ru.ru_utime);
  case TotalCPU:  return to_usec(ru.ru_stime) + to_usec(ru.ru_utime);
  default: assert(false);
  }
  return 0;
}