Module: xenomai-3
Branch: next
Commit: e2ee98d281a900518329c260dcbcdc42ca1c3671
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e2ee98d281a900518329c260dcbcdc42ca1c3671

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Jun 16 14:24:44 2015 +0200

testsuite/latency: dump configuration data along with gnuplot output

At this chance, also recognizes "-" as stdout for -g option.

---

 testsuite/latency/latency.c |   41 ++++++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index f76e3e8..8aab398 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -382,14 +382,36 @@ static double dump_histogram(int32_t *histogram, char 
*kind)
 
 static void dump_histo_gnuplot(int32_t *histogram)
 {
-       unsigned start, stop;
-       FILE *f;
+       unsigned int start, stop;
+       char *xconf, buf[BUFSIZ];
+       FILE *ifp, *ofp;
        int n;
 
-       f = fopen(do_gnuplot, "w");
-       if (!f)
-               return;
+       if (strcmp(do_gnuplot, "-") == 0)
+               ofp = stdout;
+       else {
+               ofp = fopen(do_gnuplot, "w");
+               if (ofp == NULL)
+                       return;
+       }
+
+       if (asprintf(&xconf, "%s/bin/xeno-config --info", CONFIG_XENO_PREFIX) < 
0)
+               goto dump_data;
+
+       ifp = popen(xconf, "r");
+       free(xconf);
+       if (ifp == NULL)
+               goto dump_data;
+
+       while (fgets(buf, sizeof(buf), ifp)) {
+               fputc('#', ofp);
+               fputc(' ', ofp);
+               fputs(buf, ofp);
+       }
+
+       fclose(ifp);
 
+dump_data:
        for (n = 0; n < histogram_size && histogram[n] == 0; n++)
                ;
        start = n;
@@ -398,13 +420,14 @@ static void dump_histo_gnuplot(int32_t *histogram)
                ;
        stop = n;
 
-       fprintf(f, "%g 1\n", start * bucketsize / 1000.0);
+       fprintf(ofp, "%g 1\n", start * bucketsize / 1000.0);
        for (n = start; n <= stop; n++)
-               fprintf(f, "%g %d\n",
+               fprintf(ofp, "%g %d\n",
                        (n + 0.5) * bucketsize / 1000.0, histogram[n] + 1);
-       fprintf(f, "%g 1\n", (stop + 1) * bucketsize / 1000.0);
+       fprintf(ofp, "%g 1\n", (stop + 1) * bucketsize / 1000.0);
 
-       fclose(f);
+       if (ofp != stdout)
+               fclose(ofp);
 }
 
 static void dump_stats(int32_t *histogram, char *kind, double avg)


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to