Latester can create historgrams from userspace timestamps
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 1 Dec 2010 15:02:57 +0000 (16:02 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 1 Dec 2010 15:02:57 +0000 (16:02 +0100)
latester/latester.c

index cb578a1..f418567 100644 (file)
@@ -60,6 +60,7 @@ struct options {
        FILE *file;
        FILE *histogram;
        int length;
+       int userhist;
 };
 
 struct options opt = {
@@ -228,9 +229,15 @@ static inline unsigned get_msg_latency_us(struct msg_info *mi)
 {
        struct timespec diff;
        if (num_interfaces == 3)
-               timespec_subtract(&diff, &mi->ts_rx_final_kern, &mi->ts_rx_onwire_kern);
+               if (opt.userhist)
+                       timespec_subtract(&diff, &mi->ts_rx_final_kern, &mi->ts_rx_onwire_kern);
+               else
+                       timespec_subtract(&diff, &mi->ts_rx_final, &mi->ts_rx_onwire);
        else
-               timespec_subtract(&diff, &mi->ts_rx_final_kern, &mi->ts_sent);
+               if (opt.userhist)
+                       timespec_subtract(&diff, &mi->ts_rx_final, &mi->ts_sent);
+               else
+                       timespec_subtract(&diff, &mi->ts_rx_final_kern, &mi->ts_sent);
        return diff.tv_sec * 1000000 + diff.tv_nsec/1000;
 }
 
@@ -268,7 +275,7 @@ static inline int sock_get_if_index(int s, const char *if_name)
 
 static inline get_tstamp(struct timespec *ts)
 {
-       clock_gettime(CLOCK_MONOTONIC, ts);
+       clock_gettime(CLOCK_REALTIME, ts);
 }
 
 int send_frame(int socket)
@@ -546,6 +553,7 @@ struct poptOption optionsTable[] = {
        { "file",   'f', POPT_ARG_STRING,                         NULL, 'f',         "File where to store results", "filename"},
        { "histogram", 'h', POPT_ARG_STRING,                      NULL, 'h',         "Store histogram in file", "filename"},
        { "length", 'l', POPT_ARG_INT|POPT_ARGFLAG_SHOW_DEFAULT,  &opt.length, 0,    "The length of generated messages", "bytes"},
+       { "userhist", 'u', POPT_ARG_NONE,                         &opt.userhist, 0,  "Generate histogram from userspace timestamps"},
        POPT_AUTOHELP
        { NULL, 0, 0, NULL, 0 }
 };