From 4d12a04740d8e01ce0e9f6129487a6efd456229b Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Wed, 1 Dec 2010 16:02:57 +0100 Subject: [PATCH] Latester can create historgrams from userspace timestamps --- latester/latester.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/latester/latester.c b/latester/latester.c index cb578a1..f418567 100644 --- a/latester/latester.c +++ b/latester/latester.c @@ -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 } }; -- 2.39.2