summarize_stats: protect against 0 renders zerodiv

This commit is contained in:
nick black 2021-07-16 00:09:48 -04:00
parent cd49a63b7b
commit 547a30e73f
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -168,7 +168,8 @@ void summarize_stats(notcurses* nc){
qprefix(stats->render_ns, NANOSECS_IN_SEC, totalbuf, 0);
qprefix(stats->render_min_ns, NANOSECS_IN_SEC, minbuf, 0);
qprefix(stats->render_max_ns, NANOSECS_IN_SEC, maxbuf, 0);
qprefix(stats->render_ns / stats->renders, NANOSECS_IN_SEC, avgbuf, 0);
qprefix(stats->renders ? stats->render_ns / stats->renders : 0,
NANOSECS_IN_SEC, avgbuf, 0);
fprintf(stderr, "%"PRIu64" render%s, %ss (%ss min, %ss avg, %ss max)\n",
stats->renders, stats->renders == 1 ? "" : "s",
totalbuf, minbuf, avgbuf, maxbuf);