summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/main.c b/main.c
index 69ad117..5cf3fc2 100644
--- a/main.c
+++ b/main.c
@@ -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;
}
}