1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #22217 from CSharperMantle:CSharperMantle-patch-steady-clock

Use `std::chrono::steady_clock` in `getTickCount`
This commit is contained in:
Alexander Smorkalov
2022-08-03 14:09:45 +03:00
committed by GitHub
+12 -2
View File
@@ -301,6 +301,9 @@ DECLARE_CV_CPUID_X86
#endif
#endif
#if defined CV_CXX11
#include <chrono>
#endif
namespace cv
{
@@ -859,7 +862,10 @@ bool useOptimized(void)
int64 getTickCount(void)
{
#if defined _WIN32 || defined WINCE
#if defined CV_CXX11
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
return (int64)now.time_since_epoch().count();
#elif defined _WIN32 || defined WINCE
LARGE_INTEGER counter;
QueryPerformanceCounter( &counter );
return (int64)counter.QuadPart;
@@ -878,7 +884,11 @@ int64 getTickCount(void)
double getTickFrequency(void)
{
#if defined _WIN32 || defined WINCE
#if defined CV_CXX11
using clock_period_t = std::chrono::steady_clock::duration::period;
double clock_freq = clock_period_t::den / clock_period_t::num;
return clock_freq;
#elif defined _WIN32 || defined WINCE
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
return (double)freq.QuadPart;