gfio: add missing disk utilization stat to end results
authorJens Axboe <axboe@kernel.dk>
Wed, 7 Mar 2012 18:51:36 +0000 (19:51 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 Mar 2012 18:51:36 +0000 (19:51 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
gfio.c

diff --git a/gfio.c b/gfio.c
index 859d178e1313a1b5f4d874ed5c1e65562d40a95e..8db04ab463695fc0137f56db2a6699040c757dab 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -900,6 +900,8 @@ static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd
        struct cmd_du_pdu *p = (struct cmd_du_pdu *) cmd->payload;
        struct gfio_client *gc = client->client_data;
        GtkWidget *box, *frame, *entry, *vbox;
+       double util;
+       char tmp[16];
 
        gdk_threads_enter();
 
@@ -955,6 +957,16 @@ static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd
        entry = new_info_entry_in_frame(vbox, "Time in queue");
        entry_set_int_value(entry, p->dus.time_in_queue);
 
+       util = 0.0;
+       if (p->dus.msec)
+               util = (double) 100 * p->dus.io_ticks / (double) p->dus.msec;
+       if (util > 100.0)
+               util = 100.0;
+
+       sprintf(tmp, "%3.2f%%", util);
+       entry = new_info_entry_in_frame(vbox, "Disk utilization");
+       gtk_entry_set_text(GTK_ENTRY(entry), tmp);
+
        gtk_widget_show_all(gc->results_widget);
 out:
        gdk_threads_leave();