Created
June 11, 2025 08:51
-
-
Save sulincix/e93518d1e0d41c662751f68e2d56b31a to your computer and use it in GitHub Desktop.
Input lag calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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