mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Vicente <vicencb@gmail.com>
To: barebox@lists.infradead.org
Cc: Vicente <vicencb@gmail.com>
Subject: [PATCH 5/5] omap4_usbboot_fs: add benchmarking capabilities
Date: Sat, 13 Oct 2012 16:03:27 +0200	[thread overview]
Message-ID: <1350137007-10135-6-git-send-email-vicencb@gmail.com> (raw)
In-Reply-To: <1350137007-10135-1-git-send-email-vicencb@gmail.com>


Signed-off-by: Vicente <vicencb@gmail.com>
---
 scripts/Makefile        |  2 +-
 scripts/omap4_usbboot.c | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/scripts/Makefile b/scripts/Makefile
index 08b325c..f3e797c 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -13,7 +13,7 @@ hostprogs-$(CONFIG_ARCH_OMAP)    += omap_signGP mk-am35xx-spi-image
 hostprogs-$(CONFIG_ARCH_S5PCxx)  += s5p_cksum
 hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader
 
-HOSTLOADLIBES_omap4_usbboot = -lpthread
+HOSTLOADLIBES_omap4_usbboot = -lpthread -lrt
 omap4_usbboot-objs               := usb_linux.o omap4_usbboot.o
 hostprogs-$(CONFIG_OMAP4_USBBOOT)+= omap4_usbboot
 
diff --git a/scripts/omap4_usbboot.c b/scripts/omap4_usbboot.c
index a276c29..e142c8a 100644
--- a/scripts/omap4_usbboot.c
+++ b/scripts/omap4_usbboot.c
@@ -20,9 +20,11 @@
 #include <sys/mman.h>
 #include <pthread.h>
 #include <termios.h>
-
+#include <time.h>
 #include "usb.h"
 
+#undef BENCHMARK
+
 #define USBBOOT_FS_MAGIC     0x5562464D
 #define USBBOOT_FS_CMD_OPEN  0x46530000
 #define USBBOOT_FS_CMD_CLOSE 0x46530001
@@ -166,6 +168,10 @@ int read_asic_id(struct usb_handle *usb)
 struct file_data {
 	size_t size;
 	void *data;
+#ifdef BENCHMARK
+	size_t readden;
+	struct timespec opened;
+#endif
 };
 
 int process_file(
@@ -175,7 +181,10 @@ int process_file(
 	struct stat s;
 	int fd, ret;
 	char fname[256];
-
+#ifdef BENCHMARK
+	struct timespec closed;
+	double ts;
+#endif
 	if (usb_read(usb, &i, 4) != 4) {
 		host_print("USB error\n");
 		exit(1);
@@ -229,6 +238,10 @@ int process_file(
 		close(fd);
 		fd_vector[i].size = size = s.st_size;
 		fd = i;
+#ifdef BENCHMARK
+		fd_vector[i].readden = 0;
+		clock_gettime(CLOCK_REALTIME, &fd_vector[i].opened);
+#endif
 		goto open_ok;
 
 open_error_2:
@@ -266,6 +279,18 @@ open_ok:
 		}
 		munmap(fd_vector[i].data, fd_vector[i].size);
 		fd_vector[i].data = NULL;
+#ifdef BENCHMARK
+		if (fd_vector[i].readden) {
+			clock_gettime(CLOCK_REALTIME, &closed);
+			ts  = closed.tv_nsec - fd_vector[i].opened.tv_nsec;
+			ts /= 1.e9;
+			ts += closed.tv_sec  - fd_vector[i].opened.tv_sec ;
+			host_print("Transferred %lu bytes"
+				"in %.2f seconds at %.2f MBps\n",
+				fd_vector[i].readden, ts,
+				fd_vector[i].readden/ts/1048576.0);
+		}
+#endif
 		break;
 	case USBBOOT_FS_CMD_READ:
 		if (usb_read(usb, &i, 4) != 4) {
@@ -308,6 +333,9 @@ open_ok:
 			host_print("could not send file to target\n");
 			exit(1);
 		}
+#ifdef BENCHMARK
+		fd_vector[i].readden += size;
+#endif
 		break;
 	case USBBOOT_FS_CMD_END:
 	default:
-- 
1.7.12.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-10-13 14:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-13 14:03 [PATCH 0/5] archosg9: improve support for tablet Vicente
2012-10-13 14:03 ` [PATCH 1/5] ArchosG9: changed serial port and env Vicente
2012-10-13 14:03 ` [PATCH 2/5] ARM: add/rename PSR bits to match linux names Vicente
2012-10-13 18:25   ` Sascha Hauer
2012-10-13 14:03 ` [PATCH 3/5] ARM: ensure irqs are disabled at barebox exit Vicente
2012-10-14  8:57   ` Sascha Hauer
2012-10-13 14:03 ` [PATCH 4/5] uimage: improve transfer speed Vicente
2012-10-13 14:03 ` Vicente [this message]
2012-10-13 18:27   ` [PATCH 5/5] omap4_usbboot_fs: add benchmarking capabilities Sascha Hauer
2012-10-13 14:19 ` [PATCH 0/5] archosg9: improve support for tablet Jean-Christophe PLAGNIOL-VILLARD
2012-10-13 14:35   ` vj
2012-10-14  8:12     ` [SPAM] " Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350137007-10135-6-git-send-email-vicencb@gmail.com \
    --to=vicencb@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox