Skip to content

Instantly share code, notes, and snippets.

@sulincix
Created June 11, 2025 08:51
Show Gist options
  • Save sulincix/e93518d1e0d41c662751f68e2d56b31a to your computer and use it in GitHub Desktop.
Save sulincix/e93518d1e0d41c662751f68e2d56b31a to your computer and use it in GitHub Desktop.
Input lag calculator
#!/usr/bin/env python3
import gi
import time
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib
cur = int(time.time()*10**6)
diff_min = 10**6
label = Gtk.Label()
def event_handler(*args):
global cur, diff_min
diff = (int(time.time()*10**6) - cur)
cur = int(time.time()*10**6)
if diff < diff_min:
diff_min = diff
label.set_text("{} µs".format(diff_min))
win = Gtk.Window()
win.connect("event", event_handler)
win.connect("touch-event", event_handler)
win.set_size_request(400,400)
win.connect("destroy", Gtk.main_quit);
win.add(label)
win.show_all()
Gtk.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment