Skip to content

AndyFilter/LatencyMeterRefreshed

Repository files navigation

LatencyMeterRefreshed

GitHub top language Windows GitHub all releases GitHub

This program lets you measure latency of your system given that you have Arduino. Now in C++!

Measure performance and latency of your PC

Are you interested in measuring the latency of your system, but can't afford a 750$ monitor? Well in that case you are not alone! This program lets you measure even the latency of a single component like mouse latency, system latency, or just overall latency. For not more than 10$!

What will you need

  • Arduino (I used UNO, but I think it will work with others too, you will just need to change the second line in the loop function to utilize digitalRead function instead of reading directly from the registers.)

  • Some jumper wires.

  • A photoresistor (I don't think the type really matters, but mine seems to be working from 300Ω to 5MΩ).

  • Like a 500Ω resistor (Not required. On Arduino Uno you can use built-in pullup resistor).

  • A button.

  • Windows 10 / 11(not tested) and basic knowledge of using it.

    How to install

  1. Make sure you are in possession of an Arduino or other microcontroller that allows for serial communication with a PC.
  2. Connect the Arduino to the other elements as follows:

Light_Sensor - A0,
Button - D2

I would recommend putting a 500Ω resistor in series with the light sensor. The button is configured to use arduino-UNO's built-in "pullup resistor" (button, INPUT_PULLUP).

Reminder! The button is reversed, It means that the code detects press of a button normally, but the state is different (if (buttonState == LOW)). All it means is that you plug it to digital pin 2 and to ground.

For the ease of use I would suggest connecting photoresistor not on the same board as the button, even better just don't use a board for it! Because you will need to place it in the correct place of your monitor.

LightsensorLatencyMeterTrans

  1. Connect the Arduino (or the microcontroller of choice) to the PC via USB.
  2. Upload the Code onto the board.
  3. Download the latest release of the program.

How to use

  1. Make sure you have everything wired up as shown in the schematic above
  2. Connect the Arduino to the PC via USB.
  3. Open the program and set the correct serial port of the Arduino.
  4. Move the photoresistor so that it looks at the black rectangle at the bottom of the program.
  5. Press Connect. If everything goes right, the program should not close, and you should see no errors.
  6. Press the Button connected to the PIN 2 of the Arduino.
  7. The measurements should appear on the screen!
  8. You can now Save them, and if that's not your first time using the program you can even Open the saves you exported earlier!

Internal Mode

This mode uses a sensor connected to a 3.5mm jack microphone input instead of a microcontroller. So, you will have to connect a photoresistor to a microphone jack cable. Or in case of doing audio latency tests, you won't have to do nothing assuming you have a microphone with a 3.5mm jack.

FAQ

  • How to enter Full Screen mode?
    • Alt+Enter
  • Audio Latency doesn’t work!
    • There is a chance that your microphone uses inverse signal, in which case you will just need to change how the Arduino interprets the sensor data. For example change the first line in the "loop" function in your Arduino code to "LDRValue = 1024 - analogRead(LDR);". As you can see it takes analogue value of the sensor and re-maps it from [0, 1024] -> [1024, 0].

Notes

Please update the program's refresh rate to for example 2x your monitor's refresh rate.
Also keep in mind that when V-Sync is OFF, the program will use 100% of the logical core it's running on.
When using Internal Mode I tend to get results with about 1 to 2 ms higher latency.

Modifications

If you want to change for example the baud rate, you will not only need to change it in the program's code, but also the microcontroller's code. It is done that way to save on cpu cycles on the Arduino part. I could make it so that you can change the baud rate from the program itself, but the current value of 19200 allows for sub millisecond delays and is reliable. All this makes it kind of pointless to change it to 9600 or maybe even 152000. With that said, I think the program could benefit from things like custom delay between measurements etc. I might look into that and check if it adds any significant latency, if not; expect it in some future update.

Questions and Issues

If you have any kind of question or issue to report. DM me through Discord: IsPossible, or create an issue on GitHub

Edits & Forks

Feel free to fork the project. Tweak, fix and add to the code. I tried to add as many useful comments to the code as it's possible, so code should be easy to read. I'll be fixing and adding to the code myself, when I'll see a need to.