From f8718b41a21fa51202f465dbe4238892e9f2f647 Mon Sep 17 00:00:00 2001
From: Michael Gernoth <michael@gernoth.net>
Date: Fri, 5 Jul 2013 10:22:19 +0200
Subject: [PATCH 1/1] add USB send-duration to debug output

---
 hmcfgusb.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/hmcfgusb.c b/hmcfgusb.c
index 0bcb5ae..1ba9b24 100644
--- a/hmcfgusb.c
+++ b/hmcfgusb.c
@@ -29,6 +29,7 @@
 #include <math.h>
 #include <poll.h>
 #include <errno.h>
+#include <sys/time.h>
 #include <libusb-1.0/libusb.h>
 
 #include "hexdump.h"
@@ -143,9 +144,14 @@ int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len
 {
 	int err;
 	int cnt;
+	struct timeval tv_start, tv_end;
+	int msec;
 
-	if (debug)
+	if (debug) {
 		hexdump(send_data, len, "USB < ");
+		gettimeofday(&tv_start, NULL);
+	}
+
 	err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, send_data, len, &cnt, USB_TIMEOUT);
 	if (err) {
 		fprintf(stderr, "Can't send data: %s\n", usb_strerror(err));
@@ -160,6 +166,12 @@ int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len
 		}
 	}
 
+	if (debug) {
+		gettimeofday(&tv_end, NULL);
+		msec = ((tv_end.tv_sec-tv_start.tv_sec)*1000)+((tv_end.tv_usec-tv_start.tv_usec)/1000);
+		fprintf(stderr, "send took %dms!\n", msec);
+	}
+
 	return 1;
 }
 
-- 
2.39.5