- mtime = mtime_since_now(&prev_time);
- if (mtime > 1000) {
- r_rate = (io_bytes[0] - prev_io_bytes[0]) / mtime;
- w_rate = (io_bytes[1] - prev_io_bytes[1]) / mtime;
- fio_gettime(&prev_time, NULL);
- memcpy(prev_io_bytes, io_bytes, sizeof(io_bytes));
+ fio_gettime(&now, NULL);
+ rate_time = mtime_since(&rate_prev_time, &now);
+
+ if (write_bw_log && rate_time> bw_avg_time) {
+ calc_rate(rate_time, io_bytes, rate_io_bytes, rate);
+ memcpy(&rate_prev_time, &now, sizeof(now));
+ add_agg_sample(rate[DDIR_READ], DDIR_READ);
+ add_agg_sample(rate[DDIR_WRITE], DDIR_WRITE);