diff options
-rw-r--r-- | fs.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -48,6 +48,7 @@ enum { Qnew, Qn, Qctl, + Qstats, Qframe, Qscene, }; @@ -67,6 +68,7 @@ Dirtab dirtab[] = { [Qnew] "new", 0666, [Qn] nil, DMDIR|0555, [Qctl] "ctl", 0666, + [Qstats] "stats", 0444, [Qframe] "frame", 0444, [Qscene] "scene", 0666, }; @@ -163,6 +165,7 @@ resetcamera(Camera *c) c->rctl = renderer; placecamera(c, Pt3(0,0,100,1), Pt3(0,0,0,1), Vec3(0,1,0)); reloadcamera(c); + memset(&c->stats, 0, sizeof c->stats); } static ulong @@ -416,6 +419,16 @@ fsread(Req *r) readstr(r, buf); respond(r, nil); break; + case Qstats: + n = snprint(buf, sizeof buf, "fps %.0f/%.0f/%.0f/%.0f\n", + !c->cam->stats.max? 0: 1e9/c->cam->stats.max, + !c->cam->stats.avg? 0: 1e9/c->cam->stats.avg, + !c->cam->stats.min? 0: 1e9/c->cam->stats.min, + !c->cam->stats.v? 0: 1e9/c->cam->stats.v); + snprint(buf+n, sizeof(buf)-n, "frame #%llud\n", c->cam->stats.nframes); + readstr(r, buf); + respond(r, nil); + break; case Qframe: fb = c->cam->vp->getfb(c->cam->vp); i = fb->cb; |