Author Topic: Measuring keyboard input latency  (Read 2183 times)

0 Members and 1 Guest are viewing this topic.

Offline mathisart

  • Thread Starter
  • Posts: 15
Measuring keyboard input latency
« on: Thu, 13 July 2023, 22:25:32 »
Does anyone have resources that talk about measuring keyboard input latency without using a high-speed camera, ideally "software-only" methods (for various platforms: Linux, Windows, etc)?

Offline bondonin

  • Posts: 33
Re: Measuring keyboard input latency
« Reply #1 on: Sat, 15 July 2023, 05:32:23 »
rtings has a database of reviews which measure latency.
Nvidia has a free tool to measure latency in gaming ( I think), so if you have an nvidia gpu you could use that.

Offline sigtrap

  • Posts: 1
Re: Measuring keyboard input latency
« Reply #2 on: Mon, 17 July 2023, 15:30:48 »
For an exact measurement you probably would require a specialized setup, consisting of a modified firmware doing two things: 1.) measures the clock cycles passed between the keystroke was registered and the the clock when the USB transfer has been send to the bus 2.) generating two or more USB transfers with a known delay in between containing their timestamps as payload. On the host side you then would need a dedicated user space driver to evaluate these transfers syncing on the first one, so you can measure the deviation on the following. Contrary to the considerable effort of writing specialized FW and driver, such a setup still would be affected by the kernels scheduling.
Also high-speed cameras wonīt get you too far, as not only their time resolution is restricted to <1000 FPS on most models and normal monitors even more.
The most practical approach coming to my mind would be to capture some of your USB traffic with a tool like Wireshark. USB protocol is always host controlled, following a request-response pattern. So all you have to do is to check your capture file for matching transfers and look up the delay between them. Even if this not exactly the latency it still gives you an idea how long your keyboard takes to respond.

@bondonin: Without knowing the nVidia tool exactly, I would assume they are more interested in the rendering latency, meaning the time it takes to transform some drawing commands sent to the GPU into pixels shown on you monitor. Whatīs going on inside a USB-host controller, itīs kernel mode driver or even inside of a HID usually is beyond the scope and accesibility of such a tool.

Offline mathisart

  • Thread Starter
  • Posts: 15
Re: Measuring keyboard input latency
« Reply #3 on: Tue, 18 July 2023, 06:32:41 »
This is nice information, thank you bondonin and sigtrap.

I do happen to have control over the firmware, so maybe at some point I'll have time to set up something like that, Christ willing.
But writing a kernel driver to receive the packets may be complicated, not sure.

I've read keyboard input latency can be as high as 60 ms, and never under 15 ms (even with 1000 Hz USB full-speed), so even an iPhone at 240 fps should be enough to measure that: danluu.com/keyboard-latency/
(This is a lot of latency btw, since man can distinguish <10ms latency: youtube.com/watch?v=vOvQCPLkPt4)

Offline tp4tissue

  • * Destiny Supporter
  • Posts: 13565
  • Location: Official Geekhack Public Defender..
  • OmniExpert of: Rice, Top-Ramen, Ergodox, n Females
Re: Measuring keyboard input latency
« Reply #4 on: Thu, 20 July 2023, 07:31:52 »
This is mostly a waste of time, games are not designed around ms accuracy. In multiplayer games, because of roll-back net code, ms accuracy will hardly matter when you put it through the grinder that's internet latency.