// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics) // SPDX-FileCopyrightText: 2021 Jorrit Rouwe // SPDX-License-Identifier: MIT #include #include #if defined(JPH_PLATFORM_WINDOWS) JPH_SUPPRESS_WARNING_PUSH JPH_MSVC_SUPPRESS_WARNING(5039) // winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. #define WIN32_LEAN_AND_MEAN #ifndef JPH_COMPILER_MINGW #include #else #include #endif JPH_SUPPRESS_WARNING_POP #endif JPH_SUPPRESS_WARNINGS_STD_BEGIN #include JPH_SUPPRESS_WARNINGS_STD_END JPH_NAMESPACE_BEGIN static uint64 sReferenceTick; static std::chrono::high_resolution_clock::time_point sReferenceTime; #if defined(JPH_PLATFORM_WINDOWS_UWP) || (defined(JPH_PLATFORM_WINDOWS) && defined(JPH_CPU_ARM)) uint64 GetProcessorTickCount() { LARGE_INTEGER count; QueryPerformanceCounter(&count); return uint64(count.QuadPart); } #endif // JPH_PLATFORM_WINDOWS_UWP || (JPH_PLATFORM_WINDOWS && JPH_CPU_ARM) void UpdateReferenceTime() { sReferenceTick = GetProcessorTickCount(); sReferenceTime = std::chrono::high_resolution_clock::now(); } uint64 GetProcessorTicksPerSecond() { uint64 ticks = GetProcessorTickCount(); std::chrono::high_resolution_clock::time_point time = std::chrono::high_resolution_clock::now(); return (ticks - sReferenceTick) * 1000000000ULL / std::chrono::duration_cast(time - sReferenceTime).count(); } JPH_NAMESPACE_END