ref: 8551f75ceaafd6678d8e489abfa82f5b414ef42a
parent: 0ec7a0bbcae886a0d36dbe931a3ed0b0e0be1089
author: rodri <[email protected]>
date: Fri Apr 5 04:37:11 EDT 2024
add a stats file for camera statistics.
--- a/fs.c
+++ b/fs.c
@@ -48,6 +48,7 @@
Qnew,
Qn,
Qctl,
+ Qstats,
Qframe,
Qscene,
};
@@ -67,6 +68,7 @@
[Qnew] "new", 0666,
[Qn] nil, DMDIR|0555,
[Qctl] "ctl", 0666,
+ [Qstats] "stats", 0444,
[Qframe] "frame", 0444,
[Qscene] "scene", 0666,
};
@@ -163,6 +165,7 @@
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
@@ -413,6 +416,16 @@
break;
case Qctl:
snprint(buf, sizeof buf, "%llud", SLOT(path));
+ 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;