Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

valleyofdoom/TimerResolution

Repository files navigation

TimerResolution

MeasureSleep is used to measure the precision of Sleep(n). By default, it sits in an infinite loop measuring the sleep deltas, but you can use the --samples argument to get average and STDEV metrics.

SetTimerResolution is used to request a higher resolution by calling NtSetTimerResolution. As an example to automatically start a hidden instance of the program when the system starts and raise the resolution to 0.5ms, place the binary somewhere safe and create a scheduled task in task scheduler (instructions) with the command below as an example.

C:\SetTimerResolution.exe --resolution 5000 --no-console

According to a comment on the Great Rule Change article, on Windows Server 2022+ and Windows 11+, the registry key below can also be used so that requesting a higher resolution is effective on a system-wide level rather than only the calling process. This should only be used for debugging purposes.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
"GlobalTimerResolutionRequests"=dword:00000001

Precision vs. Resolution Graph

The micro-adjust-benchmark.ps1 script can be used to automate the process of plotting precision against resolutions. The results can be visualized with chart-studio.plotly.com.

Building

git clone https://github.com/valleyofdoom/TimerResolution.git
cd .\TimerResolution\
# x64
$env:VCPKG_DEFAULT_TRIPLET = "x64-windows"
# install dependencies
vcpkg install
# replace "SetTimerResolution" with "MeasureSleep" if desired
MSBuild.exe .\TimerResolution.sln -p:Configuration=Release -p:Platform=x64 -t:SetTimerResolution

About

Raise the clock interrupt frequency in Windows

Resources

Readme

License

GPL-3.0 license

Stars

Watchers

Forks

Packages