Skip to content

Instantly share code, notes, and snippets.

@Sporif
Created September 19, 2021 20:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sporif/314d5796e48ff0e9f63ec5b89f967b66 to your computer and use it in GitHub Desktop.
Save Sporif/314d5796e48ff0e9f63ec5b89f967b66 to your computer and use it in GitHub Desktop.
Allow evhz to detect refresh rates higher than 1000Hz (https://git.sr.ht/~iank/evhz)
diff --git a/evhz.c b/evhz.c
index 3b4d0cf..c7ba33d 100644
--- a/evhz.c
+++ b/evhz.c
@@ -118,13 +118,13 @@ int main(int argc, char *argv[]) {
unsigned long long time, timediff;
unsigned hz = 0;
- time = (unsigned long long)event.time.tv_sec * 1000ULL;
- time += (unsigned long long)event.time.tv_usec / 1000ULL;
+ time = (unsigned long long)event.time.tv_sec * 1000000ULL;
+ time += (unsigned long long)event.time.tv_usec;
timediff = time - events[i].prev_time;
if(timediff != 0)
- hz = 1000ULL / timediff;
+ hz = 1000000ULL / timediff;
if(hz > 0) {
unsigned j, maxavg;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment