.NET Framework/.NET Core RT System.Stopwatch.IsHighResolution 只读字段属性怎么在C++上面进行实现?

C++ 实现:

        bool Stopwatch::IsHighResolution() noexcept
        {
#if defined(_WIN32)
            LARGE_INTEGER frequency;
            if (QueryPerformanceFrequency(&frequency))
            {
                return true;
            }
#elif defined(_LINUX) || defined(_ANDROID)
            return clock_gettime(CLOCK_MONOTONIC, &ts) == 0;
#elif defined(_MACOS)
            mach_timebase_info_data_t timebase;
            mach_timebase_info(&timebase);

            return timebase.numer == 1 && timebase.denom == 1;
#else
            return std::chrono::high_resolution_clock::period::den >= std::micro::den; // microseconds
#endif
        }

你可能感兴趣的:(C/C++,c++)