From 6c7b40debf8034bbe2076cacd1c497bc24b5218e Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 21 Apr 2021 11:42:59 -0400 Subject: [PATCH] add stats for sprixel emissions/elisions #1563 --- NEWS.md | 3 +++ USAGE.md | 2 ++ doc/man/man3/notcurses_stats.3.md | 6 ++++++ include/notcurses/notcurses.h | 2 ++ src/lib/stats.c | 7 +++++++ 5 files changed, 20 insertions(+) diff --git a/NEWS.md b/NEWS.md index 253e639b2..f0651309e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. +* 2.2.9 (not yet released) + * Added two new stats, `sprixelemissions` and `sprixelelisions`. + * 2.2.8 (2021-04-18) * All remaining functions prefixed with `cell_` or `cells_` have been deprecated in favor of versions prefixed with `nccell_` or `nccell_`, diff --git a/USAGE.md b/USAGE.md index 76475e6ce..2b291104c 100644 --- a/USAGE.md +++ b/USAGE.md @@ -3328,6 +3328,8 @@ typedef struct ncstats { uint64_t defaultelisions; // default color was emitted uint64_t defaultemissions; // default color was elided uint64_t refreshes; // refresh requests (non-optimized redraw) + uint64_t sprixelemissions; // sprixel draw count + uint64_t sprixelelisions; // sprixel elision count // current state -- these can decrease uint64_t fbbytes; // total bytes devoted to all active framebuffers diff --git a/doc/man/man3/notcurses_stats.3.md b/doc/man/man3/notcurses_stats.3.md index 89d60e4d8..e92fc40c2 100644 --- a/doc/man/man3/notcurses_stats.3.md +++ b/doc/man/man3/notcurses_stats.3.md @@ -38,6 +38,8 @@ typedef struct ncstats { uint64_t defaultelisions; // default color was emitted uint64_t defaultemissions; // default color was elided uint64_t refreshes; // refreshes (unoptimized redraws) + uint64_t sprixelemissions; // sprixel draw count + uint64_t sprixelelisions; // sprixel elision count // current state -- these can decrease uint64_t fbbytes; // bytes devoted to framebuffers @@ -102,6 +104,10 @@ the **struct notcurses** context. **planes** is the number of planes in the context. Neither of these stats can reach 0, due to the mandatory standard plane. +**sprixelemissions** is the number of sprixel draws. **sprixelelisions** is +the number of times a sprixel was elided--essentially, the number of times +a sprixel appeared in a rendered frame without freshly drawing it. + # NOTES Unsuccessful render operations do not contribute to the render timing stats. diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 0974b7342..f531e6e8b 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1417,6 +1417,8 @@ typedef struct ncstats { uint64_t raster_ns; // nanoseconds spent rasterizing int64_t raster_max_ns; // max ns spent in raster for a frame int64_t raster_min_ns; // min ns spent in raster for a frame + uint64_t sprixelemissions; // sprixel draw count + uint64_t sprixelelisions; // sprixel elision count } ncstats; // Allocate an ncstats object. Use this rather than allocating your own, since diff --git a/src/lib/stats.c b/src/lib/stats.c index ed4ca7c28..11295cf94 100644 --- a/src/lib/stats.c +++ b/src/lib/stats.c @@ -141,6 +141,9 @@ void notcurses_stats_reset(notcurses* nc, ncstats* stats){ stash->defaultelisions += nc->stats.defaultelisions; stash->defaultemissions += nc->stats.defaultemissions; stash->refreshes += nc->stats.refreshes; + stash->sprixelemissions += nc->stats.sprixelemissions; + stash->sprixelelisions += nc->stats.sprixelelisions; + stash->fbbytes = nc->stats.fbbytes; stash->planes = nc->stats.planes; reset_stats(&nc->stats); @@ -208,5 +211,9 @@ void summarize_stats(notcurses* nc){ (stats->fgelisions * 100.0) / (stats->fgemissions + stats->fgelisions), (stats->bgemissions + stats->bgelisions) == 0 ? 0 : (stats->bgelisions * 100.0) / (stats->bgemissions + stats->bgelisions)); + fprintf(stderr, "Sprixel emits:elides: %ju/%ju (%.2f%%)\n", + stats->sprixelemissions, stats->sprixelelisions, + (stats->sprixelemissions + stats->sprixelelisions) == 0 ? 0 : + (stats->sprixelelisions * 100.0) / (stats->sprixelemissions + stats->sprixelelisions)); } }