Newer
Older
Import / projects / Gameloft / core / Time / HighResolutionClock.h
@John John on 29 Dec 2020 943 bytes bulk import from macbookpro checkouts
#ifndef __UTIL_HIGH_RES_CLOCK_INCLUDED__
#define __UTIL_HIGH_RES_CLOCK_INCLUDED__

#include <chrono>  // NOLINT(build/c++11)

namespace GameTime
{

#if defined(GAME_WIN32)
  // In Visual Studio <= 2013 the implementation of high_resolution_clock is not very high precision
  // http://stackoverflow.com/questions/16299029/resolution-of-stdchronohigh-resolution-clock-doesnt-correspond-to-measureme
  struct HighResClock
  {
    typedef uint64_t                                rep;
    typedef std::nano                               period;
    typedef std::chrono::duration<rep, period>      duration;
    typedef std::chrono::time_point<HighResClock>   time_point;
    static const bool is_steady = true;

    static time_point now();
  };

  typedef HighResClock high_resolution_clock;
#else
  typedef std::chrono::high_resolution_clock high_resolution_clock;
#endif
}
#endif // __UTIL_HIGH_RES_CLOCK_INCLUDED__