summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@google.com>2010-03-11 06:36:11 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-03-11 06:36:11 -0800
commitbde9e134bd9d43017fe964093bc20f1036c6e3fc (patch)
treee4a191a97fe796f621c7de6f19e1e4092d6ddf35
parent95ee753a5e5822548d25c926f1ee71b2fe5dad1c (diff)
parentcb6e22b687eee5a47c642620d2e995b60f60f3e7 (diff)
downloadsystem_core-bde9e134bd9d43017fe964093bc20f1036c6e3fc.zip
system_core-bde9e134bd9d43017fe964093bc20f1036c6e3fc.tar.gz
system_core-bde9e134bd9d43017fe964093bc20f1036c6e3fc.tar.bz2
Merge "Add wall-clock timing for each fastboot Action."
-rw-r--r--fastboot/engine.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/fastboot/engine.c b/fastboot/engine.c
index 4c7e197..6d62c6e 100644
--- a/fastboot/engine.c
+++ b/fastboot/engine.c
@@ -30,9 +30,17 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <sys/time.h>
#include "fastboot.h"
+double now()
+{
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
+}
+
char *mkmsg(const char *fmt, ...)
{
char buf[256];
@@ -66,6 +74,8 @@ struct Action
const char *msg;
int (*func)(Action *a, int status, char *resp);
+
+ double start;
};
static Action *action_list = 0;
@@ -76,7 +86,9 @@ static int cb_default(Action *a, int status, char *resp)
if (status) {
fprintf(stderr,"FAILED (%s)\n", resp);
} else {
- fprintf(stderr,"OKAY\n");
+ double split = now();
+ fprintf(stderr,"OKAY [%7.3fs]\n", (split - a->start));
+ a->start = split;
}
return status;
}
@@ -101,6 +113,9 @@ static Action *queue_action(unsigned op, const char *fmt, ...)
action_last = a;
a->op = op;
a->func = cb_default;
+
+ a->start = -1;
+
return a;
}
@@ -166,7 +181,9 @@ static int cb_check(Action *a, int status, char *resp, int invert)
if (invert) yes = !yes;
if (yes) {
- fprintf(stderr,"OKAY\n");
+ double split = now();
+ fprintf(stderr,"OKAY [%7.3fs]\n", (split - a->start));
+ a->start = split;
return 0;
}
@@ -263,9 +280,12 @@ void fb_execute_queue(usb_handle *usb)
a = action_list;
resp[FB_RESPONSE_SZ] = 0;
+ double start = -1;
for (a = action_list; a; a = a->next) {
+ a->start = now();
+ if (start < 0) start = a->start;
if (a->msg) {
- fprintf(stderr,"%s... ",a->msg);
+ fprintf(stderr,"%30s... ",a->msg);
}
if (a->op == OP_DOWNLOAD) {
status = fb_download_data(usb, a->data, a->size);
@@ -285,5 +305,7 @@ void fb_execute_queue(usb_handle *usb)
die("bogus action");
}
}
+
+ fprintf(stderr,"finished. total time: %.3fs\n", (now() - start));
}