idletime: fix potential divide-by-zero
[fio.git] / idletime.c
index c0bc0bfce19675e311fcbd7394540b02a7010eba..bc8097680d69f37b139495b61f56287b588c9693 100644 (file)
@@ -336,7 +336,10 @@ void fio_idle_prof_stop(void)
                /* calculate idleness */
                if (ipc.cali_mean != 0.0) {
                        runt = utime_since(&ipt->tps, &ipt->tpe);
-                       ipt->idleness = ipt->loops * ipc.cali_mean / runt;
+                       if (runt)
+                               ipt->idleness = ipt->loops * ipc.cali_mean / runt;
+                       else
+                               ipt->idleness = 0.0;
                } else
                        ipt->idleness = 0.0;
        }