gfio: add missing disk utilization stat to end results
[fio.git] / gfio.c
diff --git a/gfio.c b/gfio.c
index b38b4900d34e00c2ab29e9997a4e0482debe5e6c..8db04ab463695fc0137f56db2a6699040c757dab 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -94,6 +94,8 @@ struct gui {
 #define DRAWING_AREA_XDIM 1000
 #define DRAWING_AREA_YDIM 400
        GtkWidget *drawing_area;
+       int drawing_area_xdim;
+       int drawing_area_ydim;
        GtkWidget *error_info_bar;
        GtkWidget *error_label;
        GtkWidget *results_notebook;
@@ -121,18 +123,6 @@ struct gfio_client {
        GtkWidget *disk_util_frame;
 };
 
-static void add_invisible_data(struct graph *g)
-{
-       /*
-        * This puts some invisible data into a graph so that it will
-        * initially have some grid lines instead of "No good data"
-        */
-       graph_add_label(g, "invisible");
-       graph_set_color(g, "invisible", INVISIBLE_COLOR, 0.0, 0.7);
-       graph_add_xy_data(g, "invisible", 0.0, 0.0);
-       graph_add_xy_data(g, "invisible", 1.0, 100.0);
-}
-
 static void setup_iops_graph(struct gui *ui)
 {
        if (ui->iops_graph)
@@ -143,9 +133,9 @@ static void setup_iops_graph(struct gui *ui)
        graph_x_title(ui->iops_graph, "Time (secs)");
        graph_add_label(ui->iops_graph, "Read IOPS");
        graph_add_label(ui->iops_graph, "Write IOPS");
-       graph_set_color(ui->iops_graph, "Read IOPS", 0.7, 0.0, 0.0);
-       graph_set_color(ui->iops_graph, "Write IOPS", 0.0, 0.0, 0.7);
-       add_invisible_data(ui->iops_graph);
+       graph_set_color(ui->iops_graph, "Read IOPS", 0.13, 0.54, 0.13);
+       graph_set_color(ui->iops_graph, "Write IOPS", 1.0, 0.0, 0.0);
+       line_graph_set_data_count_limit(ui->iops_graph, 100);
 }
 
 static void setup_bandwidth_graph(struct gui *ui)
@@ -158,9 +148,9 @@ static void setup_bandwidth_graph(struct gui *ui)
        graph_x_title(ui->bandwidth_graph, "Time (secs)");
        graph_add_label(ui->bandwidth_graph, "Read Bandwidth");
        graph_add_label(ui->bandwidth_graph, "Write Bandwidth");
-       graph_set_color(ui->bandwidth_graph, "Read Bandwidth", 0.7, 0.0, 0.0);
-       graph_set_color(ui->bandwidth_graph, "Write Bandwidth", 0.0, 0.0, 0.7);
-       add_invisible_data(ui->bandwidth_graph);
+       graph_set_color(ui->bandwidth_graph, "Read Bandwidth", 0.13, 0.54, 0.13);
+       graph_set_color(ui->bandwidth_graph, "Write Bandwidth", 1.0, 0.0, 0.0);
+       line_graph_set_data_count_limit(ui->bandwidth_graph, 100);
 }
 
 static void clear_ui_info(struct gui *ui)
@@ -910,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();
 
@@ -965,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();
@@ -1007,11 +1009,22 @@ static void gfio_group_stats_op(struct fio_client *client,
        gdk_threads_leave();
 }
 
+static gint on_config_drawing_area(GtkWidget *w, GdkEventConfigure *event)
+{
+       ui.drawing_area_xdim = w->allocation.width;
+       ui.drawing_area_ydim = w->allocation.height;
+       return TRUE;
+}
+
 static int on_expose_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p)
 {
        struct gui *ui = (struct gui *) p;
        cairo_t *cr;
 
+       graph_set_size(ui->iops_graph, ui->drawing_area_xdim / 2.0,
+                                       ui->drawing_area_ydim);
+       graph_set_size(ui->bandwidth_graph, ui->drawing_area_xdim / 2.0,
+                                       ui->drawing_area_ydim);
        cr = gdk_cairo_create(w->window);
 
        cairo_set_source_rgb(cr, 0, 0, 0);
@@ -1023,8 +1036,7 @@ static int on_expose_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p)
        cairo_restore(cr);
 
        cairo_save(cr);
-       cairo_translate(cr, DRAWING_AREA_XDIM / 2.0, 0);
-                               // DRAWING_AREA_YDIM * 0.05);
+       cairo_translate(cr, ui->drawing_area_xdim / 2.0, 0);
        line_graph_draw(ui->iops_graph, cr);
        cairo_stroke(cr);
        cairo_restore(cr);
@@ -1923,11 +1935,15 @@ static void init_ui(int *argc, char **argv[], struct gui *ui)
         */
        gdk_color_parse("white", &white);
        ui->drawing_area = gtk_drawing_area_new();
+       ui->drawing_area_xdim = DRAWING_AREA_XDIM;
+       ui->drawing_area_ydim = DRAWING_AREA_YDIM;
        gtk_widget_set_size_request(GTK_WIDGET(ui->drawing_area), 
-                       DRAWING_AREA_XDIM, DRAWING_AREA_YDIM);
+                       ui->drawing_area_xdim, ui->drawing_area_ydim);
        gtk_widget_modify_bg(ui->drawing_area, GTK_STATE_NORMAL, &white);
        g_signal_connect(G_OBJECT(ui->drawing_area), "expose_event",
                                G_CALLBACK (on_expose_drawing_area), ui);
+       g_signal_connect(G_OBJECT(ui->drawing_area), "configure_event",
+                               G_CALLBACK (on_config_drawing_area), ui);
        ui->scrolled_window = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ui->scrolled_window),
                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);