From: Laurent MAZET Date: Mon, 29 Sep 2025 13:59:51 +0000 (+0200) Subject: improve histogram X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=0ecc2f065bd12e8ead4e7bb05332bc3aa6bc36c7;p=benchmarks.git improve histogram --- diff --git a/stat.c b/stat.c index f39d441..b7f4643 100644 --- a/stat.c +++ b/stat.c @@ -1,14 +1,15 @@ /* statistic module */ #include -#include #include #include #include #include "stat.h" -void compute_statistics (int64_t *points, int nb, int bins) +#define STEP 20 + +void compute_statistics (unsigned int *points, int nb, int bins) { printf ("Nb of points = %d\n", nb); @@ -50,7 +51,7 @@ void compute_statistics (int64_t *points, int nb, int bins) int change_done = 0; for (int i = 1; i < nb - 1; i++) { if (points[i + 1] < points[i]) { - int64_t tmp = points[i]; + unsigned int tmp = points[i]; points[i] = points[i + 1]; points[i + 1] = tmp; change_done = 1; @@ -93,6 +94,10 @@ void compute_statistics (int64_t *points, int nb, int bins) printf ("Histogram (%d)\n", nb); for (int i = 0; i < bins; i++) { + int h = (STEP * hist[i] + nb / 2 - 1) / nb; + for (int j = 0; j < STEP; j++) { + printf ("%c", (j < h) ? '#' : ' '); + } printf (" [%.2lf - %.2lf] = %d\n", min + i * gap, min + (i + 1) * gap, hist[i]); }