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...
This commit is contained in:
Daniel Eklöf 2019-12-31 20:26:30 +01:00
parent a45786ef1b
commit 60b27a9686
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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 */