mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
implement raster timing stats #1324
This commit is contained in:
parent
ddc524420d
commit
94172303be
@ -475,14 +475,12 @@ summary_table(struct ncdirect* nc, const char* spec, bool canimage, bool canvide
|
||||
}
|
||||
qprefix(nsdelta, NANOSECS_IN_SEC, timebuf, 0);
|
||||
bprefix(totalbytes, 1, totalbuf, 0);
|
||||
//qprefix(totalrenderns, NANOSECS_IN_SEC, rtimebuf, 0);
|
||||
table_segment(nc, "", "══╧════════╧════════╪═══════╪═════════╪═══════╪══╧══╧══╧═══════╝\n");
|
||||
table_segment(nc, "", "══╧════════╧════════╪═══════╪═════════╪═══════╧══╧══╧══╧═══════╝\n");
|
||||
printf(" ");
|
||||
table_printf(nc, "│", "%*ss", PREFIXFMT(timebuf));
|
||||
table_printf(nc, "│", "%7lu", totalframes);
|
||||
table_printf(nc, "│", "%*s", BPREFIXFMT(totalbuf));
|
||||
//table_printf(nc, "│", " %*ss", PREFIXFMT(rtimebuf));
|
||||
table_printf(nc, "│", "%7.1f", nsdelta ? totalframes / ((double)nsdelta / NANOSECS_IN_SEC) : 0);
|
||||
//table_printf(nc, "│", "%7.1f", nsdelta ? totalframes / ((double)nsdelta / NANOSECS_IN_SEC) : 0);
|
||||
printf("\n");
|
||||
ncdirect_set_fg_rgb8(nc, 0xff, 0xb0, 0xb0);
|
||||
fflush(stdout); // in case we print to stderr below, we want color from above
|
||||
|
@ -15,10 +15,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_MONOTONIC_RAW
|
||||
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
|
||||
#endif
|
||||
|
||||
// configured via command line option -- the base number of ns between demos
|
||||
extern struct timespec demodelay;
|
||||
extern float delaymultiplier; // scales demodelay (applied internally)
|
||||
|
@ -147,7 +147,7 @@ int intro(struct notcurses* nc){
|
||||
ncplane_off_styles(ncp, NCSTYLE_BLINK); // heh FIXME replace with pulse
|
||||
}
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
uint64_t deadline = timespec_to_ns(&now) + timespec_to_ns(&demodelay) * 2;
|
||||
int flipmode = 0;
|
||||
do{
|
||||
@ -158,7 +158,7 @@ int intro(struct notcurses* nc){
|
||||
struct timespec iter;
|
||||
timespec_div(&demodelay, 10, &iter);
|
||||
demo_nanosleep(nc, &iter);
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
}while(timespec_to_ns(&now) < deadline);
|
||||
if(!notcurses_canfade(nc)){
|
||||
return 0;
|
||||
|
@ -278,7 +278,7 @@ int trans_demo(struct notcurses* nc){
|
||||
struct ncplane* l = legend(nc, "what say we explore transparency together?");
|
||||
DEMO_RENDER(nc);
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
int err;
|
||||
if( (err = ncplane_pulse(l, &demodelay, pulser, &now)) != 2){
|
||||
return err;
|
||||
|
@ -152,6 +152,23 @@ update_render_stats(const struct timespec* time1, const struct timespec* time0,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_raster_stats(const struct timespec* time1, const struct timespec* time0,
|
||||
ncstats* stats){
|
||||
const int64_t elapsed = timespec_to_ns(time1) - timespec_to_ns(time0);
|
||||
//fprintf(stderr, "Rasterizing took %ld.%03lds\n", elapsed / NANOSECS_IN_SEC,
|
||||
// (elapsed % NANOSECS_IN_SEC) / 1000000);
|
||||
if(elapsed > 0){ // don't count clearly incorrect information, egads
|
||||
stats->raster_ns += elapsed;
|
||||
if(elapsed > stats->raster_max_ns){
|
||||
stats->raster_max_ns = elapsed;
|
||||
}
|
||||
if(elapsed < stats->raster_min_ns){
|
||||
stats->raster_min_ns = elapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cell_release(ncplane* n, nccell* c){
|
||||
pool_release(&n->pool, c);
|
||||
}
|
||||
@ -1174,18 +1191,20 @@ ncpile_render_internal(ncplane* n, struct crender* rvec, int leny, int lenx,
|
||||
}
|
||||
|
||||
int ncpile_rasterize(ncplane* n){
|
||||
struct timespec start, writedone;
|
||||
struct timespec start, rasterdone, writedone;
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
const ncpile* pile = ncplane_pile(n);
|
||||
struct notcurses* nc = ncplane_notcurses(n);
|
||||
const int miny = pile->dimy < nc->lfdimy ? pile->dimy : nc->lfdimy;
|
||||
const int minx = pile->dimx < nc->lfdimx ? pile->dimx : nc->lfdimx;
|
||||
postpaint(nc->lastframe, miny, minx, pile->crender, &nc->pool);
|
||||
clock_gettime(CLOCK_MONOTONIC, &rasterdone);
|
||||
int bytes = notcurses_rasterize(nc, pile, nc->rstate.mstreamfp);
|
||||
// accepts -1 as an indication of failure
|
||||
update_render_bytes(&nc->stats, bytes);
|
||||
clock_gettime(CLOCK_MONOTONIC, &writedone);
|
||||
update_write_stats(&writedone, &start, &nc->stats, bytes);
|
||||
update_raster_stats(&rasterdone, &start, &nc->stats);
|
||||
update_write_stats(&writedone, &rasterdone, &nc->stats, bytes);
|
||||
if(bytes < 0){
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user