*/
void do_verify(struct thread_data *td)
{
- struct timeval t;
struct io_u *io_u, *v_io_u = NULL;
struct io_completion_data icd;
struct fio_file *f;
if (td->terminate)
break;
- gettimeofday(&t, NULL);
- if (runtime_exceeded(td, &t))
- break;
-
io_u = __get_io_u(td);
if (!io_u)
break;
+ if (runtime_exceeded(td, &io_u->start_time)) {
+ put_io_u(td, io_u);
+ break;
+ }
+
if (get_next_verify(td, io_u)) {
put_io_u(td, io_u);
break;
v_io_u = td->io_ops->event(td, 0);
icd.nr = 1;
icd.error = 0;
+ fio_gettime(&icd.time, NULL);
io_completed(td, v_io_u, &icd);
if (icd.error) {
int i = 0;
while (!td->terminate) {
- gettimeofday(&e, NULL);
+ fio_gettime(&e, NULL);
if (runtime_exceeded(td, &e))
break;
static void do_io(struct thread_data *td)
{
struct io_completion_data icd;
- struct timeval s, e;
+ struct timeval s;
unsigned long usec;
struct fio_file *f;
int i, ret = 0;
* of completions except the very first one which may look
* a little bursty
*/
- gettimeofday(&e, NULL);
- usec = utime_since(&s, &e);
+ usec = utime_since(&s, &icd.time);
rate_throttle(td, usec, icd.bytes_done[td->ddir], td->ddir);
- if (check_min_rate(td, &e)) {
+ if (check_min_rate(td, &icd.time)) {
if (exitall_on_terminate)
terminate_threads(td->groupid);
td_verror(td, ENOMEM);
break;
}
- if (runtime_exceeded(td, &e))
+ if (runtime_exceeded(td, &icd.time))
break;
if (td->thinktime)
*/
static void *thread_main(void *data)
{
+ unsigned long long runtime[2];
struct thread_data *td = data;
if (!td->use_thread)
if (open_files(td))
goto err;
- gettimeofday(&td->epoch, NULL);
-
if (td->exec_prerun)
system(td->exec_prerun);
+ fio_gettime(&td->epoch, NULL);
+
+ runtime[0] = runtime[1] = 0;
while (td->loops--) {
getrusage(RUSAGE_SELF, &td->ru_start);
- gettimeofday(&td->start, NULL);
+ fio_gettime(&td->start, NULL);
memcpy(&td->stat_sample_time, &td->start, sizeof(td->start));
if (td->ratemin)
else
do_io(td);
- td->runtime[td->ddir] += mtime_since_now(&td->start);
+ runtime[td->ddir] += utime_since_now(&td->start);
if (td_rw(td) && td->io_bytes[td->ddir ^ 1])
- td->runtime[td->ddir ^ 1] = td->runtime[td->ddir];
+ runtime[td->ddir ^ 1] = runtime[td->ddir];
update_rusage_stat(td);
continue;
clear_io_state(td);
- gettimeofday(&td->start, NULL);
+ fio_gettime(&td->start, NULL);
do_verify(td);
- td->runtime[DDIR_READ] += mtime_since_now(&td->start);
+ runtime[DDIR_READ] += utime_since_now(&td->start);
if (td->error || td->terminate)
break;
}
+ fio_gettime(&td->end_time, NULL);
+ td->runtime[0] = runtime[0] / 1000;
+ td->runtime[1] = runtime[1] / 1000;
+
if (td->bw_log)
finish_log(td, td->bw_log, "bw");
if (td->slat_log)
}
}
- time_init();
-
while (todo) {
struct thread_data *map[MAX_JOBS];
struct timeval this_start;
* Wait for the started threads to transition to
* TD_INITIALIZED.
*/
- gettimeofday(&this_start, NULL);
+ fio_gettime(&this_start, NULL);
left = this_jobs;
while (left) {
if (mtime_since_now(&this_start) > JOB_START_TIMEOUT)