X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=time.c;h=d08c791673f55b8139be5ec20cc757a891913423;hp=52462633a5fccc3791105aef65f64e708001c7f7;hb=6043c5790f9978814ec25e3ea8f4d574daf6266e;hpb=6796209a7e3d39522b0f5599aba277809786335e diff --git a/time.c b/time.c index 52462633..d08c7916 100644 --- a/time.c +++ b/time.c @@ -3,6 +3,8 @@ #include "fio.h" +static struct timeval genesis; + unsigned long utime_since(struct timeval *s, struct timeval *e) { double sec, usec; @@ -60,7 +62,7 @@ unsigned long time_since_now(struct timeval *s) /* * busy looping version for the last few usec */ -static void __usec_sleep(unsigned int usec) +void __usec_sleep(unsigned int usec) { struct timeval start; @@ -97,14 +99,14 @@ void usec_sleep(struct thread_data *td, unsigned long usec) } void rate_throttle(struct thread_data *td, unsigned long time_spent, - unsigned int bytes) + unsigned int bytes, int ddir) { unsigned long usec_cycle; if (!td->rate) return; - usec_cycle = td->rate_usec_cycle * (bytes / td->min_bs); + usec_cycle = td->rate_usec_cycle * (bytes / td->min_bs[ddir]); if (time_spent < usec_cycle) { unsigned long s = usec_cycle - time_spent; @@ -120,3 +122,18 @@ void rate_throttle(struct thread_data *td, unsigned long time_spent, td->rate_pending_usleep -= overtime; } } + +unsigned long mtime_since_genesis(void) +{ + return mtime_since_now(&genesis); +} + +void time_init(void) +{ + gettimeofday(&genesis, NULL); +} + +void fill_start_time(struct timeval *t) +{ + memcpy(t, &genesis, sizeof(genesis)); +}