]> rtime.felk.cvut.cz Git - can-benchmark.git/blobdiff - latester/histogram.h
Merge branch 'master' of ssh://rtime.felk.cvut.cz/can-benchmark
[can-benchmark.git] / latester / histogram.h
index ad7591ccccf7f1220f80d3488307ff6560da0cd5..80d629e32d4a9518c90884d54bfabdde3847863a 100644 (file)
@@ -23,8 +23,9 @@ int histogram_init(struct histogram *h,
                return -1;
 }
 
-void histogram_add(struct histogram *h, unsigned value)
+void histogram_add(struct histogram *h, int value)
 {
+       if (value < 0) value = 0;
        unsigned index = value / h->resolution;
        if (index >= h->allocated)
                index = h->allocated - 1;
@@ -35,15 +36,16 @@ void histogram_fprint(struct histogram *h, FILE *f)
 {
        unsigned long long sum = 0, cum;
        unsigned i;
+
+       if (!f)
+               return;
+
        for (i = 0; i < h->allocated; i++)
                sum += h->data[i];
        cum = sum;
        for (i = 0; i < h->allocated; i++) {
                if (h->data[i] != 0) {
-                       if (!getenv("CANPING_MS"))
-                               fprintf(f, "%d %lld\n", i*h->resolution, cum);
-                       else
-                               fprintf(f, "%g %lld\n", 1e-3*(i*h->resolution), cum);
+                       fprintf(f, "%g %lld\n", 1e-3*(i*h->resolution), cum);
                }
                cum -= h->data[i];
        }