summaryrefslogtreecommitdiff
path: root/blkparse_fmt.c
diff options
context:
space:
mode:
authorOlaf Kirch <okir@lst.de>2006-12-01 10:34:11 +0100
committerJens Axboe <jens.axboe@oracle.com>2006-12-01 10:34:11 +0100
commit7bd4fd0a4fca645bb50a641afac1e460a4e32dfd (patch)
tree3b07ba4c6f2b5245dd6a70e0657cf90b6638338b /blkparse_fmt.c
parentb22050b50f412c4c6567eebbcd2f3364e74908d9 (diff)
downloadblktrace-7bd4fd0a4fca645bb50a641afac1e460a4e32dfd.tar.gz
blktrace-7bd4fd0a4fca645bb50a641afac1e460a4e32dfd.tar.bz2
[PATCH] Add timestamp support
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'blkparse_fmt.c')
-rw-r--r--blkparse_fmt.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index f74832d..bc38114 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
+#include <time.h>
#include "blktrace.h"
@@ -85,6 +86,31 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
rwbs[i] = '\0';
}
+static const char *
+print_time(unsigned long long timestamp)
+{
+ static char timebuf[128];
+ struct tm *tm;
+ time_t sec;
+ unsigned long nsec;
+
+ sec = abs_start_time.tv_sec + SECONDS(timestamp);
+ nsec = abs_start_time.tv_nsec + NANO_SECONDS(timestamp);
+ if (nsec >= 1000000000) {
+ nsec -= 1000000000;
+ sec += 1;
+ }
+
+ tm = localtime(&sec);
+ snprintf(timebuf, sizeof(timebuf),
+ "%02u:%02u:%02u.%06lu",
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec,
+ nsec / 1000);
+ return timebuf;
+}
+
static inline int pdu_rest_is_zero(unsigned char *pdu, int len)
{
static char zero[4096];
@@ -221,10 +247,12 @@ static void print_field(char *act, struct per_cpu_info *pci,
}
fprintf(ofp, strcat(format, "llu"), elapsed / 1000);
break;
- case 'U': {
+ case 'U':
fprintf(ofp, strcat(format, "u"), get_pdu_int(t));
break;
- }
+ case 'z':
+ fprintf(ofp, strcat(format, "s"), print_time(t->time));
+ break;
default:
fprintf(ofp,strcat(format, "c"), field);
break;