fix ramp_in

There are a couple of problems with the relatively new ramp_in feature
of fio.  First, the estimated time to completion did not correctly take
it into account and bounces around.  Second and more importantly, the
runtime was including ramp in time in throughput calculations even
though the IO done during that time was ignored, thus making throughput
metrics incorrect. This patch fixes both.

Signed-off-by Steven Pratt <slpratt@austin.ibm.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
diff --git a/fio.c b/fio.c
index 91bf6b6..8dff813 100644
--- a/fio.c
+++ b/fio.c
@@ -989,6 +989,8 @@
 	}
 	
 	fio_gettime(&tv, NULL);
+	td->ts.runtime[0] = 0;
+	td->ts.runtime[1] = 0;
 	memcpy(&td->epoch, &tv, sizeof(tv));
 	memcpy(&td->start, &tv, sizeof(tv));
 }
@@ -1027,7 +1029,7 @@
  */
 static void *thread_main(void *data)
 {
-	unsigned long long runtime[2], elapsed;
+	unsigned long long elapsed;
 	struct thread_data *td = data;
 	pthread_condattr_t attr;
 	int clear_state;
@@ -1145,7 +1147,6 @@
 	fio_gettime(&td->epoch, NULL);
 	getrusage(RUSAGE_SELF, &td->ts.ru_start);
 
-	runtime[0] = runtime[1] = 0;
 	clear_state = 0;
 	while (keep_running(td)) {
 		fio_gettime(&td->start, NULL);
@@ -1170,11 +1171,11 @@
 
 		if (td_read(td) && td->io_bytes[DDIR_READ]) {
 			elapsed = utime_since_now(&td->start);
-			runtime[DDIR_READ] += elapsed;
+			td->ts.runtime[DDIR_READ] += elapsed;
 		}
 		if (td_write(td) && td->io_bytes[DDIR_WRITE]) {
 			elapsed = utime_since_now(&td->start);
-			runtime[DDIR_WRITE] += elapsed;
+			td->ts.runtime[DDIR_WRITE] += elapsed;
 		}
 
 		if (td->error || td->terminate)
@@ -1191,15 +1192,15 @@
 
 		do_verify(td);
 
-		runtime[DDIR_READ] += utime_since_now(&td->start);
+		td->ts.runtime[DDIR_READ] += utime_since_now(&td->start);
 
 		if (td->error || td->terminate)
 			break;
 	}
 
 	update_rusage_stat(td);
-	td->ts.runtime[0] = (runtime[0] + 999) / 1000;
-	td->ts.runtime[1] = (runtime[1] + 999) / 1000;
+	td->ts.runtime[0] = (td->ts.runtime[0] + 999) / 1000;
+	td->ts.runtime[1] = (td->ts.runtime[1] + 999) / 1000;
 	td->ts.total_run_time = mtime_since_now(&td->epoch);
 	td->ts.io_bytes[0] = td->io_bytes[0];
 	td->ts.io_bytes[1] = td->io_bytes[1];