Basic C++ mouse tester

Everything about latency. Tips, testing methods, mouse lag, display lag, game engine lag, network lag, whole input lag chain, VSYNC OFF vs VSYNC ON, and more! Input Lag Articles on Blur Busters.
Post Reply
Aeodyn
Posts: 9
Joined: 19 Feb 2024, 15:42

Basic C++ mouse tester

Post by Aeodyn » 23 Mar 2024, 20:30

I've adapted a very basic mouse raw input tester in C++: https://gitlab.com/Aeodyn/cpp-rawinput
The main advantages are that it's single-threaded and uses TSC as the clock source plus QPC for wall clock sync, so as long as your CPU is Nehalem (2008) or newer, it should work great.

To use it, double-click it, start moving your mouse, hit the spacebar to start recording, keep moving your mouse, and hit space again to stop recording and write the results to rawinput.csv.
Command line args:
-p [path]: Output to [path] instead of rawinput.csv.
-k [key code]: Use a different virual key code (https://learn.microsoft.com/en-us/windo ... -key-codes) instead of space (0x20).
-b: Busy-wait while recording. Should give better results if it has a core all to itself, worse otherwise. Most games don't busy-wait.
-n: No capture. By default it captures the mouse.
-c [core]: Which cpu/core to lock the thread to. By default it will lock to whatever it starts on. 0-indexed.

To graph it, use the "rel" column as X and the "dt" column as Y, or better do a linear fit to (k,rel) and plot the residuals.

I also recommend merging this to your registry so that Windows doesn't "helpfully" add in some extra threads:

Code: Select all

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\rawinput.exe]
"MaxLoaderThreads"=dword:00000001
Attachments
rawinput.zip
(98.76 KiB) Downloaded 9 times
Last edited by Aeodyn on 24 Mar 2024, 00:37, edited 1 time in total.

pox02
Posts: 262
Joined: 28 Sep 2018, 06:04

Re: Basic C++ mouse tester

Post by pox02 » 23 Mar 2024, 21:05

u forgot SetThreadAffinityMask rdtscp is not multicore safe
monitors xg258q aw2518hf 27GK750F-B pg248q xg240r lg w2363d-pf xb270hu XL2546 XL2546K NXG252R

Aeodyn
Posts: 9
Joined: 19 Feb 2024, 15:42

Re: Basic C++ mouse tester

Post by Aeodyn » 23 Mar 2024, 22:08

pox02 wrote:
23 Mar 2024, 21:05
u forgot SetThreadAffinityMask rdtscp is not multicore safe
Thanks! Code look good now? Forgot since I was running it with cmd's `start` for affinity/priority.

pox02
Posts: 262
Joined: 28 Sep 2018, 06:04

Re: Basic C++ mouse tester

Post by pox02 » 24 Mar 2024, 00:24

Aeodyn wrote:
23 Mar 2024, 22:08
pox02 wrote:
23 Mar 2024, 21:05
u forgot SetThreadAffinityMask rdtscp is not multicore safe
Thanks! Code look good now? Forgot since I was running it with cmd's `start` for affinity/priority.
good
monitors xg258q aw2518hf 27GK750F-B pg248q xg240r lg w2363d-pf xb270hu XL2546 XL2546K NXG252R

BumFlannel
Posts: 8
Joined: 31 Oct 2022, 08:33

Re: Basic C++ mouse tester

Post by BumFlannel » 24 Mar 2024, 17:27

I'm assuming this looks bad?

Image

pox02
Posts: 262
Joined: 28 Sep 2018, 06:04

Re: Basic C++ mouse tester

Post by pox02 » 24 Mar 2024, 22:04

Aeodyn wrote:
23 Mar 2024, 22:08
pox02 wrote:
23 Mar 2024, 21:05
u forgot SetThreadAffinityMask rdtscp is not multicore safe
Thanks! Code look good now? Forgot since I was running it with cmd's `start` for affinity/priority.
i suggest make it run in first core
monitors xg258q aw2518hf 27GK750F-B pg248q xg240r lg w2363d-pf xb270hu XL2546 XL2546K NXG252R

Post Reply