elide some stats output lines when unpopulated

This commit is contained in:
nick black 2021-08-07 23:36:37 -04:00
parent dda6ef69ca
commit 4070245c4f
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 41 additions and 38 deletions

View File

@ -188,7 +188,7 @@ launch_pipe_process(int* pipefd, int* pidfd){
#else #else
(void)pipefd; (void)pipefd;
(void)pidfd; (void)pidfd;
return NULL; return -1;
#endif #endif
} }

View File

@ -10,11 +10,10 @@ extern "C" {
#include "notcurses/notcurses.h" #include "notcurses/notcurses.h"
#include "compat/compat.h" #include "compat/compat.h"
#include <ncurses.h> // needed for some definitions, see terminfo(3ncurses)
#include <term.h> #include <term.h>
#include <ncurses.h>
#include <time.h> #include <time.h>
#include <term.h> #include <term.h>
#include <ncurses.h> // needed for some definitions, see terminfo(3ncurses)
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <unistd.h> #include <unistd.h>

View File

@ -165,41 +165,45 @@ void summarize_stats(notcurses* nc){
char minbuf[BPREFIXSTRLEN + 1]; char minbuf[BPREFIXSTRLEN + 1];
char maxbuf[BPREFIXSTRLEN + 1]; char maxbuf[BPREFIXSTRLEN + 1];
char avgbuf[BPREFIXSTRLEN + 1]; char avgbuf[BPREFIXSTRLEN + 1];
qprefix(stats->render_ns, NANOSECS_IN_SEC, totalbuf, 0); if(stats->renders){
qprefix(stats->render_min_ns, NANOSECS_IN_SEC, minbuf, 0); qprefix(stats->render_ns, NANOSECS_IN_SEC, totalbuf, 0);
qprefix(stats->render_max_ns, NANOSECS_IN_SEC, maxbuf, 0); qprefix(stats->render_min_ns, NANOSECS_IN_SEC, minbuf, 0);
qprefix(stats->renders ? stats->render_ns / stats->renders : 0, qprefix(stats->render_max_ns, NANOSECS_IN_SEC, maxbuf, 0);
NANOSECS_IN_SEC, avgbuf, 0); qprefix(stats->render_ns / stats->renders, NANOSECS_IN_SEC, avgbuf, 0);
fprintf(stderr, "%"PRIu64" render%s, %ss (%ss min, %ss avg, %ss max)\n", fprintf(stderr, "%"PRIu64" render%s, %ss (%ss min, %ss avg, %ss max)\n",
stats->renders, stats->renders == 1 ? "" : "s", stats->renders, stats->renders == 1 ? "" : "s",
totalbuf, minbuf, avgbuf, maxbuf); totalbuf, minbuf, avgbuf, maxbuf);
qprefix(stats->raster_ns, NANOSECS_IN_SEC, totalbuf, 0); }
qprefix(stats->raster_min_ns, NANOSECS_IN_SEC, minbuf, 0); if(stats->writeouts || stats->failed_writeouts){
qprefix(stats->raster_max_ns, NANOSECS_IN_SEC, maxbuf, 0); qprefix(stats->raster_ns, NANOSECS_IN_SEC, totalbuf, 0);
qprefix((stats->writeouts || stats->failed_writeouts) ? qprefix(stats->raster_min_ns, NANOSECS_IN_SEC, minbuf, 0);
stats->raster_ns / (stats->writeouts + stats->failed_writeouts) qprefix(stats->raster_max_ns, NANOSECS_IN_SEC, maxbuf, 0);
: 0, NANOSECS_IN_SEC, avgbuf, 0); qprefix(stats->raster_ns / (stats->writeouts + stats->failed_writeouts),
fprintf(stderr, "%"PRIu64" raster%s, %ss (%ss min, %ss avg, %ss max)\n", NANOSECS_IN_SEC, avgbuf, 0);
stats->writeouts, stats->writeouts == 1 ? "" : "s", fprintf(stderr, "%"PRIu64" raster%s, %ss (%ss min, %ss avg, %ss max)\n",
totalbuf, minbuf, avgbuf, maxbuf); stats->writeouts, stats->writeouts == 1 ? "" : "s",
qprefix(stats->writeout_ns, NANOSECS_IN_SEC, totalbuf, 0); totalbuf, minbuf, avgbuf, maxbuf);
qprefix(stats->writeout_ns ? stats->writeout_min_ns : 0, qprefix(stats->writeout_ns, NANOSECS_IN_SEC, totalbuf, 0);
NANOSECS_IN_SEC, minbuf, 0); qprefix(stats->writeout_ns ? stats->writeout_min_ns : 0,
qprefix(stats->writeout_max_ns, NANOSECS_IN_SEC, maxbuf, 0); NANOSECS_IN_SEC, minbuf, 0);
qprefix(stats->writeouts ? stats->writeout_ns / stats->writeouts : 0, qprefix(stats->writeout_max_ns, NANOSECS_IN_SEC, maxbuf, 0);
NANOSECS_IN_SEC, avgbuf, 0); qprefix(stats->writeouts ? stats->writeout_ns / stats->writeouts : 0,
fprintf(stderr, "%"PRIu64" write%s, %ss (%ss min, %ss avg, %ss max)\n", NANOSECS_IN_SEC, avgbuf, 0);
stats->writeouts, stats->writeouts == 1 ? "" : "s", fprintf(stderr, "%"PRIu64" write%s, %ss (%ss min, %ss avg, %ss max)\n",
totalbuf, minbuf, avgbuf, maxbuf); stats->writeouts, stats->writeouts == 1 ? "" : "s",
bprefix(stats->render_bytes, 1, totalbuf, 1), totalbuf, minbuf, avgbuf, maxbuf);
bprefix(stats->render_bytes ? stats->render_min_bytes : 0, }
1, minbuf, 1), if(stats->renders || stats->input_events){
bprefix(stats->renders ? stats->render_bytes / stats->renders : 0, 1, avgbuf, 1); bprefix(stats->render_bytes, 1, totalbuf, 1),
bprefix(stats->render_max_bytes, 1, maxbuf, 1), bprefix(stats->render_bytes ? stats->render_min_bytes : 0,
fprintf(stderr, "%sB (%sB min, %sB avg, %sB max) %"PRIu64" input%s\n", 1, minbuf, 1),
totalbuf, minbuf, avgbuf, maxbuf, bprefix(stats->renders ? stats->render_bytes / stats->renders : 0, 1, avgbuf, 1);
stats->input_events, bprefix(stats->render_max_bytes, 1, maxbuf, 1),
stats->input_events == 1 ? "" : "s"); fprintf(stderr, "%sB (%sB min, %sB avg, %sB max) %"PRIu64" input%s\n",
totalbuf, minbuf, avgbuf, maxbuf,
stats->input_events,
stats->input_events == 1 ? "" : "s");
}
fprintf(stderr, "%"PRIu64" failed render%s, %"PRIu64" failed raster%s, %"PRIu64" refresh%s, %"PRIu64" input error%s\n", fprintf(stderr, "%"PRIu64" failed render%s, %"PRIu64" failed raster%s, %"PRIu64" refresh%s, %"PRIu64" input error%s\n",
stats->failed_renders, stats->failed_renders == 1 ? "" : "s", stats->failed_renders, stats->failed_renders == 1 ? "" : "s",
stats->failed_writeouts, stats->failed_writeouts == 1 ? "" : "s", stats->failed_writeouts, stats->failed_writeouts == 1 ? "" : "s",