From 211b3192f05c4120fa2dd0e23988e74bdd310830 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 19 Sep 2014 15:48:24 +0200 Subject: fdo#84000: Reimplement the Windows WinSalTimer using Timer Queues. Timer Queues http://msdn.microsoft.com/en-us/library/windows/desktop/ms686796%28v=vs.85%29.aspx allow creating & maintaing high-precision timers. This commit switches the WinSalTimer implementation from using the Timers: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644900%28v=vs.85%29.aspx to Timer Queue Timers. The 'classic' Timers do not have better precision than some 15.6ms (the documentation mentions 10ms, but some measuring seems to confirm that it is more than that). With the Timer Queue Timers, we now have 1ms precision. Incorporates some cleanup from Michael Meeks . Change-Id: I0312a0c9fdc2779258698b24389b24c39e643473 --- tools/source/datetime/ttime.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx index 0b147b443c33..71836e721689 100644 --- a/tools/source/datetime/ttime.cxx +++ b/tools/source/datetime/ttime.cxx @@ -400,7 +400,19 @@ Time Time::GetUTCOffset() sal_uIntPtr Time::GetSystemTicks() { #if defined WNT - return (sal_uIntPtr)GetTickCount(); + static LARGE_INTEGER nTicksPerMS; + static bool bTicksPerMSInitialized = false; + if (!bTicksPerMSInitialized) + { + QueryPerformanceFrequency(&nTicksPerMS); + nTicksPerMS.QuadPart /= 1000; + bTicksPerMSInitialized = true; + } + + LARGE_INTEGER nPerformanceCount; + QueryPerformanceCounter(&nPerformanceCount); + + return (sal_uIntPtr)(nPerformanceCount.QuadPart/nTicksPerMS.QuadPart); #else timeval tv; gettimeofday (&tv, 0); -- cgit