diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -116,15 +116,32 @@ kbdproc(void*) } } +enum{ Frameslice = 1000/30 }; void drawproc(void *arg) { Channel *c; - - c = arg; - for(;;){ - send(c, nil); - sleep(FPS2MS(60)); + vlong t0, t, dt, tt; + int fps; + + c = arg; + fps = 0; + tt = 0; + t0 = nsec(); + for(;;){ + send(c, nil); + t = nsec(); + dt = t-t0; + fps++; + tt += dt; + if(tt >= 1e9){ + fprint(2, "fps %d\n", fps); + tt = fps = 0; + } + dt /= 1e6; + if(dt < Frameslice) + sleep(Frameslice - dt); + t0 = t; } } |