btrace2fio: add rate output
authorJens Axboe <axboe@kernel.dk>
Wed, 17 Sep 2014 15:58:31 +0000 (17:58 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 17 Sep 2014 15:58:31 +0000 (17:58 +0200)
Signed-off-by: Jens Axboe <axboe@fb.com>
t/btrace2fio.c

index bda3c0bf9f4d8906dc7b2f21a56da31790151319..4dff3ec3f16f08c27af51fc852303a3f5739c06e 100644 (file)
@@ -46,6 +46,7 @@ struct btrace_out {
        unsigned int depth;
        uint64_t first_ttime;
        uint64_t last_ttime;
        unsigned int depth;
        uint64_t first_ttime;
        uint64_t last_ttime;
+       uint64_t kb;
 
        uint64_t start_delay;
 };
 
        uint64_t start_delay;
 };
@@ -365,8 +366,10 @@ static void handle_trace(struct blk_io_trace *t, struct btrace_pid *p)
                struct inflight *i;
 
                i = inflight_find(t->sector + (t->bytes >> 9));
                struct inflight *i;
 
                i = inflight_find(t->sector + (t->bytes >> 9));
-               if (i)
+               if (i) {
+                       i->p->o.kb += (t->bytes >> 10);
                        inflight_remove(i);
                        inflight_remove(i);
+               }
        }
 }
 
        }
 }
 
@@ -509,7 +512,7 @@ static void __output_p_ascii(struct btrace_pid *p, unsigned long *ios)
 {
        const char *msg[] = { "reads", "writes", "trims" };
        struct btrace_out *o = &p->o;
 {
        const char *msg[] = { "reads", "writes", "trims" };
        struct btrace_out *o = &p->o;
-       unsigned long total;
+       unsigned long total, usec;
        int i, j;
 
        printf("[pid:\t%u]\n", p->pid);
        int i, j;
 
        printf("[pid:\t%u]\n", p->pid);
@@ -539,7 +542,9 @@ static void __output_p_ascii(struct btrace_pid *p, unsigned long *ios)
        }
 
        printf("depth:\t%u\n", o->depth);
        }
 
        printf("depth:\t%u\n", o->depth);
-       printf("usec:\t%llu (delay=%llu)\n", (o->last_ttime - o->first_ttime) / 1000ULL, (unsigned long long) o->start_delay);
+       usec = (o->last_ttime - o->first_ttime) / 1000ULL;
+       printf("usec:\t%lu (delay=%llu)\n", usec, (unsigned long long) o->start_delay);
+       printf("rate:\t%.2fKB/sec\n", ((float) o->kb * 1000.0) / ((float) usec / 1000.0));
 
        printf("files:\t");
        for (i = 0; i < p->nr_files; i++)
 
        printf("files:\t");
        for (i = 0; i < p->nr_files; i++)