[PATCH] Improve time accounting for a job

We need to account loop time in usecs, or the null io engine can
get the timing wrong. For the system usage stats, don't use summed
up loop counts, but calculate end-start time instead.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/stat.c b/stat.c
index e6da421..731b303 100644
--- a/stat.c
+++ b/stat.c
@@ -258,9 +258,6 @@
 
 void update_rusage_stat(struct thread_data *td)
 {
-	if (!(td->runtime[0] + td->runtime[1]))
-		return;
-
 	getrusage(RUSAGE_SELF, &td->ru_end);
 
 	td->usr_time += mtime_since(&td->ru_start.ru_utime, &td->ru_end.ru_utime);
@@ -362,6 +359,7 @@
 			       struct group_run_stats *rs)
 {
 	double usr_cpu, sys_cpu;
+	unsigned long runtime;
 
 	if (!(td->io_bytes[0] + td->io_bytes[1]) && !td->error)
 		return;
@@ -372,8 +370,9 @@
 	if (td->io_bytes[td->ddir ^ 1])
 		show_ddir_status(td, rs, td->ddir ^ 1);
 
-	if (td->runtime[0] + td->runtime[1]) {
-		double runt = td->runtime[0] + td->runtime[1];
+	runtime = mtime_since(&td->epoch, &td->end_time);
+	if (runtime) {
+		double runt = runtime;
 
 		usr_cpu = (double) td->usr_time * 100 / runt;
 		sys_cpu = (double) td->sys_time * 100 / runt;