Code:
From 2e52e85eef0a15177854bff38381331d972ad7f6 Mon Sep 17 00:00:00 2001
From: Frieder Ferlemann <Frieder.Ferlemann@NOSPAMweb.de>
Date: Tue, 10 Jul 2012 22:43:37 +0200
Subject: [PATCH] showing averaged and instantaneous bars
Add overlayed bars (using '+' char) with exponential moving averages.
Used %5.1 format specifier for percentages to avoid jumping columns.
---
ui.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 56 insertions(+), 18 deletions(-)
diff --git a/ui.c b/ui.c
index 48b82cb..6e79f02 100644
--- a/ui.c
+++ b/ui.c
@@ -66,6 +66,30 @@ static void percentage(const unsigned int y, const unsigned int w, const float p
attroff(A_REVERSE);
}
+static void percentage2(const unsigned int y, const unsigned int w, const float p, const float p2) {
+
+ const unsigned int x = (w/2) + 2;
+ unsigned int len = w - x - 1;
+ unsigned int len2 = len;
+ unsigned int minlen = 0;
+
+ len = len * (p / 100.0);
+ len2 = len2 * (p2 / 100.0);
+ minlen = (len <= len2) ? len : len2;
+
+ attron(A_REVERSE);
+ mvhline(y, x, '+', minlen);
+
+ if(len <= len2) {
+ attroff(A_REVERSE);
+ mvhline(y, x+minlen, '+', len2-minlen);
+ }
+ else {
+ mvhline(y, x+minlen, ' ', len-minlen);
+ attroff(A_REVERSE);
+ }
+}
+
void present(const unsigned int ticks, const char card[], const unsigned int color) {
// This does not need to be atomic. A delay here is acceptable.
@@ -122,39 +146,53 @@ void present(const unsigned int ticks, const char card[], const unsigned int col
float cr = 100.0 * (float) results->cr / ticks;
float cb = 100.0 * (float) results->cb / ticks;
+ // determins time constant for moving averages
+ const float alpha = 0.3;
+
+ static float ee_avg = 0;
+ static float vgt_avg = 0;
+ static float gui_avg = 0;
+ static float ta_avg = 0;
+
+ // calculate exponential moving averages
+ ee_avg = ee_avg * (1 - alpha) + ee * alpha;
+ vgt_avg = vgt_avg * (1 - alpha) + vgt * alpha;
+ gui_avg = gui_avg * (1 - alpha) + gui * alpha;
+ ta_avg = ta_avg * (1 - alpha) + ta * alpha;
+
mvhline(3, 0, ACS_HLINE, w);
mvvline(1, (w/2) + 1, ACS_VLINE, h);
mvaddch(3, (w/2) + 1, ACS_PLUS);
if (color) attron(COLOR_PAIR(1));
- percentage(2, w, gui);
- printright(2, hw, _("Graphics pipe %.2f%%"), gui);
+ percentage2(2, w, gui, gui_avg);
+ printright(2, hw, _("Graphics pipe %5.1f%% %5.1f%%"), gui, gui_avg);
if (color) attroff(COLOR_PAIR(1));
unsigned int start = 4;
- percentage(start, w, ee);
- printright(start++, hw, _("Event Engine %.2f%%"), ee);
+ percentage2(start, w, ee, ee_avg);
+ printright(start++, hw, _("Event Engine %5.1f%% %5.1f%%"), ee, ee_avg);
// Enough height?
if (h > bigh) start++;
if (color) attron(COLOR_PAIR(2));
- percentage(start, w, vgt);
- printright(start++, hw, _("Vertex Grouper + Tesselator %.2f%%"), vgt);
+ percentage2(start, w, vgt, vgt_avg);
+ printright(start++, hw, _("Vertex Grouper + Tesselator %5.1f%% %5.1f%%"), vgt, vgt_avg);
if (color) attroff(COLOR_PAIR(2));
// Enough height?
if (h > bigh) start++;
if (color) attron(COLOR_PAIR(3));
- percentage(start, w, ta);
- printright(start++, hw, _("Texture Addresser %.2f%%"), ta);
+ percentage2(start, w, ta, ta_avg);
+ printright(start++, hw, _("Texture Addresser %5.1f%% %5.1f%%"), ta, ta_avg);
// This is only present on R600
if (bits.tc) {
percentage(start, w, tc);
- printright(start++, hw, _("Texture Cache %.2f%%"), tc);
+ printright(start++, hw, _("Texture Cache %5.1f%%"), tc);
}
if (color) attroff(COLOR_PAIR(3));
@@ -163,18 +201,18 @@ void present(const unsigned int ticks, const char card[], const unsigned int col
if (color) attron(COLOR_PAIR(4));
percentage(start, w, sx);
- printright(start++, hw, _("Shader Export %.2f%%"), sx);
+ printright(start++, hw, _("Shader Export %5.1f%%"), sx);
percentage(start, w, sh);
- printright(start++, hw, _("Sequencer Instruction Cache %.2f%%"), sh);
+ printright(start++, hw, _("Sequencer Instruction Cache %5.1f%%"), sh);
percentage(start, w, spi);
- printright(start++, hw, _("Shader Interpolator %.2f%%"), spi);
+ printright(start++, hw, _("Shader Interpolator %5.1f%%"), spi);
// only on R600
if (bits.smx) {
percentage(start, w, smx);
- printright(start++, hw, _("Shader Memory Exchange %.2f%%"), smx);
+ printright(start++, hw, _("Shader Memory Exchange %5.1f%%"), smx);
}
if (color) attroff(COLOR_PAIR(4));
@@ -182,25 +220,25 @@ void present(const unsigned int ticks, const char card[], const unsigned int col
if (h > bigh) start++;
percentage(start, w, sc);
- printright(start++, hw, _("Scan Converter %.2f%%"), sc);
+ printright(start++, hw, _("Scan Converter %5.1f%%"), sc);
percentage(start, w, pa);
- printright(start++, hw, _("Primitive Assembly %.2f%%"), pa);
+ printright(start++, hw, _("Primitive Assembly %5.1f%%"), pa);
// Enough height?
if (h > bigh) start++;
if (color) attron(COLOR_PAIR(5));
percentage(start, w, db);
- printright(start++, hw, _("Depth Block %.2f%%"), db);
+ printright(start++, hw, _("Depth Block %5.1f%%"), db);
percentage(start, w, cb);
- printright(start++, hw, _("Color Block %.2f%%"), cb);
+ printright(start++, hw, _("Color Block %5.1f%%"), cb);
// Only present on R600
if (bits.cr) {
percentage(start, w, cr);
- printright(start++, hw, _("Clip Rectangle %.2f%%"), cr);
+ printright(start++, hw, _("Clip Rectangle %5.1f%%"), cr);
}
if (color) attroff(COLOR_PAIR(5));
--
1.7.7