X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/blobdiff_plain/7f0bb45bf01be785d7077985aabfefeb3b2c1da2..87ae560edb2ef5f1b6b2029a3fe7c0259c45ffb1:/recvmmsg/can_recvmmsg.c diff --git a/recvmmsg/can_recvmmsg.c b/recvmmsg/can_recvmmsg.c index 4041f62..4dee5f1 100644 --- a/recvmmsg/can_recvmmsg.c +++ b/recvmmsg/can_recvmmsg.c @@ -14,12 +14,14 @@ #include #include #include +#include #define CHECK(cmd) do { if ((cmd) == -1) { perror(#cmd); exit(1); } } while (0) char *dev = "vcan0"; int count = 10000; enum { READ, RECVMMSG } recv_method = READ; +bool quiet = false; /* Subtract the `struct timespec' values X and Y, storing the result in RESULT (result = x - y). @@ -79,7 +81,7 @@ void benchmark() memset(&cf, 0, sizeof(cf)); cf.can_dlc = 8; - fprintf(stderr, "Sending %d frames\n", count); + if (!quiet) fprintf(stderr, "Sending %d frames\n", count); for (i = 0; i < count; i++) { ret = write(ss, &cf, sizeof(cf)); if (ret != sizeof(cf)) { @@ -90,7 +92,7 @@ void benchmark() switch (recv_method) { case READ: { - fprintf(stderr, "Receiving %d frames with read()\n", count); + if (!quiet) fprintf(stderr, "Receiving %d frames with read()\n", count); clock_gettime(CLOCK_MONOTONIC, &t1); for (i = 0; i < count; i++) { //fprintf(stderr, "Receiving frame %d\r", i); @@ -105,7 +107,7 @@ void benchmark() break; } case RECVMMSG: { - fprintf(stderr, "Receiving %d frames with recvmmsg()\n", count); + if (!quiet) fprintf(stderr, "Receiving %d frames with recvmmsg()\n", count); struct mmsghdr msgs[count]; struct iovec iovecs[count]; char bufs[count][sizeof(struct can_frame)]; @@ -139,7 +141,7 @@ int main(int argc, char *argv[]) { int opt; - while ((opt = getopt(argc, argv, "c:mr")) != -1) { + while ((opt = getopt(argc, argv, "c:mrq")) != -1) { switch (opt) { case 'c': count = atoi(optarg); @@ -150,6 +152,9 @@ int main(int argc, char *argv[]) case 'r': recv_method = READ; break; + case 'q': + quiet = true; + break; default: /* '?' */ fprintf(stderr, "Usage: %s [-c ] [-r] [-m] [interface]\n", argv[0]);