From 60b27a9686931986f6f62d970a1f1112720816ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Dec 2019 20:26:30 +0100 Subject: [PATCH] term: commented out code to measure time between slave output This allows us to measure the time between to refresh delays. That is, when we decide to delay a refresh, we store the current time. If we hit that code path _again_, without having refreshed, we calculate the time that has passed. This gives us an estimate for how we should set our lower delay timeout. This is of course application dependent, but is still much better than simply guessing a value... --- terminal.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/terminal.c b/terminal.c index 61c3fdfa..72dce0cc 100644 --- a/terminal.c +++ b/terminal.c @@ -117,6 +117,10 @@ fdm_ptmx_out(struct fdm *fdm, int fd, int events, void *data) return true; } +#if 0 +static struct timespec last = {0}; +#endif + static bool fdm_ptmx(struct fdm *fdm, int fd, int events, void *data) { @@ -181,6 +185,22 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data) */ if (term->window->frame_callback == NULL) { /* First timeout - reset each time we receive input. */ + +#if 0 + struct timespec now; + + clock_gettime(1, &now); + if (last.tv_sec > 0 || last.tv_nsec > 0) { + struct timeval diff; + struct timeval l = {last.tv_sec, last.tv_nsec / 1000}; + struct timeval n = {now.tv_sec, now.tv_nsec / 1000}; + + timersub(&n, &l, &diff); + LOG_INFO("waited %lu µs for more input", diff.tv_usec); + } + last = now; +#endif + timerfd_settime( term->delayed_render_timer.lower_fd, 0, &(struct itimerspec){.it_value = {.tv_nsec = 2000000}}, @@ -375,6 +395,10 @@ fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data) else if (ret2 > 0) LOG_DBG("upper delay timer expired"); +#if 0 + last = (struct timespec){0}; +#endif + render_refresh(term); /* Reset timers */