summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-05-16 19:38:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-05-17 08:04:43 +0100
commit3d0c1991fdb19211d33653c3ba8e69364d1d6927 (patch)
treee072d0ac0a8605668a0dde6d9b99546f9a5f2ad4
parent34860d9a50d0a62473d89b8753107e34c241c74d (diff)
more-ds
-rw-r--r--ministat.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/ministat.c b/ministat.c
index 96fb407..f8c4414 100644
--- a/ministat.c
+++ b/ministat.c
@@ -125,8 +125,12 @@ double student [NSTUDENT + 1][NCONF] = {
/* 100. */ { 1.290, 1.660, 1.984, 2.364, 2.626, 3.174 }
};
-#define MAX_DS 3
-static char symbol[] = { ' ', 'x', '+', '*', '%', '#', '@', 'O' };
+#define MAX_DS 8
+static char symbol[] = {
+ ' ',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
+ '+', 'x', '*', '#', '%', '&', '@'
+};
struct dataset {
char *name;
@@ -306,7 +310,7 @@ Vitals(struct dataset *ds, int flag)
{
printf("%c %3d(%3d) %13.8g %13.8g %13.8g %13.8g %13.8g",
- symbol[1 << flag], ds->n, ds->sn,
+ symbol[flag + 1], ds->n, ds->sn,
Min(ds), Max(ds), ds->median, Avg(ds), Stddev(ds));
printf("\n");
}
@@ -522,6 +526,17 @@ PlotSet(struct dataset *ds, int val)
pl->bar[bar][x] = 'A';
}
+static char plot_symbol(unsigned int x)
+{
+ if (x == 0)
+ x = 0;
+ else if ((x & (x - 1)) == 0)
+ x = __builtin_ffs(x);
+ else
+ x = __builtin_popcount(x) + MAX_DS - 1;
+ return symbol[x];
+}
+
static void
DumpPlot(void)
{
@@ -545,7 +560,7 @@ DumpPlot(void)
putchar('|');
for (j = 0; j < pl->width; j++) {
k = pl->data[(pl->height - i) * pl->width + j];
- putchar(symbol[k]);
+ putchar(plot_symbol(k));
}
putchar('|');
putchar('\n');
@@ -762,7 +777,7 @@ main(int argc, char **argv)
}
for (i = 0; i < nds; i++)
- printf("%c %s\n", symbol[1 << i], ds[i]->name);
+ printf("%c %s\n", symbol[i + 1], ds[i]->name);
if (!flag_n && !flag_q) {
SetupPlot(termwidth, flag_s, nds);