]> rtime.felk.cvut.cz Git - canping.git/commitdiff
Graphs are generated optionally in milliseconds
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 28 Aug 2009 07:25:18 +0000 (09:25 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 28 Aug 2009 07:25:18 +0000 (09:25 +0200)
This in controlled by CANPING_MS environment variable

src/vca_canping.c

index 64ea3c27289fff216dce1aa83fd9253e81dd131d..b29f465270efa2207d897623f50f7c221f26f929 100644 (file)
@@ -170,8 +170,12 @@ void histogram_fprint(struct histogram *h, FILE *f)
                sum += h->data[i];
        cum = sum;
        for (i = 0; i < h->allocated; i++) {
-               if (h->data[i] != 0)
-                       fprintf(f, "%d %lld\n", i*h->resolution, cum);
+               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);
+               }
                cum -= h->data[i];
        }
 }
@@ -402,8 +406,12 @@ void *master_thread(void *arg)
                int i;
                snprintf(buf, sizeof(buf), "%s-%d.dat", option_save_all_times, ping_id);
                f = fopen(buf, "w");
-               for (i=0; i<option_count; i++)
-                       fprintf(f, "%u\n", td->times[i]);
+               for (i=0; i<option_count; i++) {
+                       if (!getenv("CANPING_MS")) 
+                               fprintf(f, "%u\n", td->times[i]);
+                       else
+                               fprintf(f, "%g\n", 1e-3*td->times[i]);
+               }
                fclose(f);
        }