Duplicate name checks in ioengines.c
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index 337b45fd98d080b013a937af015343727499a80d..a8f2b02665b2b21f278bcef35af984dc2e61e0d0 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -11,6 +11,7 @@
 
 static struct itimerval itimer;
 static struct list_head disk_list = LIST_HEAD_INIT(disk_list);
+static dev_t last_dev;
 
 /*
  * Cheasy number->string conversion, complete with carry rounding error.
@@ -273,6 +274,17 @@ void init_disk_util(struct thread_data *td)
 
        if (disk_util_exists(dev))
                return;
+
+       /*
+        * for an fs without a device, we will repeatedly stat through
+        * sysfs which can take oodles of time for thousands of files. so
+        * cache the last lookup and compare with that before going through
+        * everything again.
+        */
+       if (dev == last_dev)
+               return;
+
+       last_dev = dev;
                
        sprintf(foo, "/sys/block");
        if (!find_block_dir(dev, foo))
@@ -454,9 +466,10 @@ static void show_thread_status(struct thread_data *td,
        else
                fprintf(f_out, "%s: (groupid=%d): err=%2d (%s): pid=%d\n",td->name, td->groupid, td->error, td->verror, td->pid);
 
-       show_ddir_status(td, rs, td->ddir);
-       if (td->io_bytes[td->ddir ^ 1])
-               show_ddir_status(td, rs, td->ddir ^ 1);
+       if (td_read(td))
+               show_ddir_status(td, rs, DDIR_READ);
+       if (td_write(td))
+               show_ddir_status(td, rs, DDIR_WRITE);
 
        runtime = mtime_since(&td->epoch, &td->end_time);
        if (runtime) {
@@ -489,8 +502,8 @@ static void show_thread_status(struct thread_data *td,
                io_u_lat[i] *= 100.0;
        }
 
-       fprintf(f_out, "     lat (msec): 2=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%, 16=%3.1f%%, 32=%3.1f%%, 64=%3.1f%%, 128=%3.1f%%\n", io_u_lat[0], io_u_lat[1], io_u_lat[2], io_u_lat[3], io_u_lat[4], io_u_lat[5], io_u_lat[6]);
-       fprintf(f_out, "     lat (msec): 256=%3.1f%%, 512=%3.1f%%, 1024=%3.1f%%, >=2048=%3.1f%%\n", io_u_lat[7], io_u_lat[8], io_u_lat[9], io_u_lat[10]);
+       fprintf(f_out, "     lat (msec): 2=%3.1f%%, 4=%3.1f%%, 10=%3.1f%%, 20=%3.1f%%, 50=%3.1f%%, 100=%3.1f%%\n", io_u_lat[0], io_u_lat[1], io_u_lat[2], io_u_lat[3], io_u_lat[4], io_u_lat[5]);
+       fprintf(f_out, "     lat (msec): 250=%3.1f%%, 500=%3.1f%%, 750=%3.1f%%, 1000=%3.1f%%, >=2000=%3.1f%%\n", io_u_lat[6], io_u_lat[7], io_u_lat[8], io_u_lat[9], io_u_lat[10]);
 
        if (td->description)
                fprintf(f_out, "%s\n", td->description);