Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Status and ETA code |
| 3 | */ |
| 4 | #include <unistd.h> |
| 5 | #include <fcntl.h> |
| 6 | #include <string.h> |
| 7 | |
| 8 | #include "fio.h" |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 9 | |
| 10 | static char run_str[MAX_JOBS + 1]; |
| 11 | |
| 12 | /* |
| 13 | * Sets the status of the 'td' in the printed status map. |
| 14 | */ |
| 15 | static void check_str_update(struct thread_data *td) |
| 16 | { |
| 17 | char c = run_str[td->thread_number - 1]; |
| 18 | |
| 19 | switch (td->runstate) { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 20 | case TD_REAPED: |
| 21 | c = '_'; |
| 22 | break; |
| 23 | case TD_EXITED: |
| 24 | c = 'E'; |
| 25 | break; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 26 | case TD_RAMP: |
| 27 | c = '/'; |
| 28 | break; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 29 | case TD_RUNNING: |
| 30 | if (td_rw(td)) { |
| 31 | if (td_random(td)) |
| 32 | c = 'm'; |
| 33 | else |
| 34 | c = 'M'; |
| 35 | } else if (td_read(td)) { |
| 36 | if (td_random(td)) |
| 37 | c = 'r'; |
| 38 | else |
| 39 | c = 'R'; |
| 40 | } else { |
| 41 | if (td_random(td)) |
| 42 | c = 'w'; |
| 43 | else |
| 44 | c = 'W'; |
| 45 | } |
| 46 | break; |
Jens Axboe | b0f6586 | 2009-05-20 11:52:15 +0200 | [diff] [blame] | 47 | case TD_PRE_READING: |
| 48 | c = 'p'; |
| 49 | break; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 50 | case TD_VERIFYING: |
| 51 | c = 'V'; |
| 52 | break; |
| 53 | case TD_FSYNCING: |
| 54 | c = 'F'; |
| 55 | break; |
| 56 | case TD_CREATED: |
| 57 | c = 'C'; |
| 58 | break; |
| 59 | case TD_INITIALIZED: |
| 60 | c = 'I'; |
| 61 | break; |
| 62 | case TD_NOT_CREATED: |
| 63 | c = 'P'; |
| 64 | break; |
| 65 | default: |
| 66 | log_err("state %d\n", td->runstate); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | run_str[td->thread_number - 1] = c; |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * Convert seconds to a printable string. |
| 74 | */ |
Gurudas Pai | 9c02f6e | 2008-06-13 08:40:11 +0200 | [diff] [blame] | 75 | static void eta_to_str(char *str, unsigned long eta_sec) |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 76 | { |
| 77 | unsigned int d, h, m, s; |
Jens Axboe | 165faf1 | 2007-02-07 11:30:37 +0100 | [diff] [blame] | 78 | int disp_hour = 0; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 79 | |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 80 | s = eta_sec % 60; |
| 81 | eta_sec /= 60; |
| 82 | m = eta_sec % 60; |
| 83 | eta_sec /= 60; |
| 84 | h = eta_sec % 24; |
| 85 | eta_sec /= 24; |
| 86 | d = eta_sec; |
| 87 | |
Jens Axboe | 165faf1 | 2007-02-07 11:30:37 +0100 | [diff] [blame] | 88 | if (d) { |
| 89 | disp_hour = 1; |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 90 | str += sprintf(str, "%02ud:", d); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 91 | } |
Jens Axboe | 165faf1 | 2007-02-07 11:30:37 +0100 | [diff] [blame] | 92 | |
| 93 | if (h || disp_hour) |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 94 | str += sprintf(str, "%02uh:", h); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 95 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 96 | str += sprintf(str, "%02um:", m); |
| 97 | str += sprintf(str, "%02us", s); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | /* |
| 101 | * Best effort calculation of the estimated pending runtime of a job. |
| 102 | */ |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 103 | static int thread_eta(struct thread_data *td) |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 104 | { |
| 105 | unsigned long long bytes_total, bytes_done; |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 106 | unsigned long eta_sec = 0; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 107 | unsigned long elapsed; |
| 108 | |
| 109 | elapsed = (mtime_since_now(&td->epoch) + 999) / 1000; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 110 | |
| 111 | bytes_total = td->total_io_size; |
| 112 | |
Jens Axboe | 74939e3 | 2006-10-19 20:37:12 +0200 | [diff] [blame] | 113 | /* |
| 114 | * if writing, bytes_total will be twice the size. If mixing, |
| 115 | * assume a 50/50 split and thus bytes_total will be 50% larger. |
| 116 | */ |
Jens Axboe | 0dd8377 | 2007-09-04 12:38:28 +0200 | [diff] [blame] | 117 | if (td->o.do_verify && td->o.verify && td_write(td)) { |
Jens Axboe | 74939e3 | 2006-10-19 20:37:12 +0200 | [diff] [blame] | 118 | if (td_rw(td)) |
| 119 | bytes_total = bytes_total * 3 / 2; |
| 120 | else |
| 121 | bytes_total <<= 1; |
| 122 | } |
| 123 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 124 | if (td->o.zone_size && td->o.zone_skip) |
| 125 | bytes_total /= (td->o.zone_skip / td->o.zone_size); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 126 | |
Shaozhi Shawn Ye | 9c5a385 | 2008-09-10 09:09:37 +0200 | [diff] [blame] | 127 | if (td->o.fill_device && td->o.size == -1ULL) |
| 128 | return 0; |
| 129 | |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 130 | if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) { |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 131 | double perc, perc_t; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 132 | |
| 133 | bytes_done = td->io_bytes[DDIR_READ] + td->io_bytes[DDIR_WRITE]; |
| 134 | perc = (double) bytes_done / (double) bytes_total; |
| 135 | if (perc > 1.0) |
| 136 | perc = 1.0; |
| 137 | |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 138 | if (td->o.time_based) { |
| 139 | perc_t = (double) elapsed / (double) td->o.timeout; |
| 140 | if (perc_t < perc) |
| 141 | perc = perc_t; |
| 142 | } |
| 143 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 144 | eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 145 | |
Jens Axboe | d3eeeab | 2008-04-06 12:19:05 +0200 | [diff] [blame] | 146 | if (td->o.timeout && |
| 147 | eta_sec > (td->o.timeout + done_secs - elapsed)) |
| 148 | eta_sec = td->o.timeout + done_secs - elapsed; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 149 | } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 150 | || td->runstate == TD_INITIALIZED |
Jens Axboe | b0f6586 | 2009-05-20 11:52:15 +0200 | [diff] [blame] | 151 | || td->runstate == TD_RAMP |
| 152 | || td->runstate == TD_PRE_READING) { |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 153 | int t_eta = 0, r_eta = 0; |
| 154 | |
| 155 | /* |
| 156 | * We can only guess - assume it'll run the full timeout |
| 157 | * if given, otherwise assume it'll run at the specified rate. |
| 158 | */ |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 159 | if (td->o.timeout) { |
Jens Axboe | d3eeeab | 2008-04-06 12:19:05 +0200 | [diff] [blame] | 160 | t_eta = td->o.timeout + td->o.start_delay; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 161 | |
| 162 | if (in_ramp_time(td)) { |
| 163 | unsigned long ramp_left; |
| 164 | |
| 165 | ramp_left = mtime_since_now(&td->start); |
| 166 | ramp_left = (ramp_left + 999) / 1000; |
| 167 | if (ramp_left <= t_eta) |
| 168 | t_eta -= ramp_left; |
| 169 | } |
| 170 | } |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 171 | if (td->o.rate[0] || td->o.rate[1]) { |
| 172 | r_eta = (bytes_total / 1024) / (td->o.rate[0] + td->o.rate[1]); |
Jens Axboe | d3eeeab | 2008-04-06 12:19:05 +0200 | [diff] [blame] | 173 | r_eta += td->o.start_delay; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | if (r_eta && t_eta) |
| 177 | eta_sec = min(r_eta, t_eta); |
| 178 | else if (r_eta) |
| 179 | eta_sec = r_eta; |
| 180 | else if (t_eta) |
| 181 | eta_sec = t_eta; |
| 182 | else |
| 183 | eta_sec = 0; |
| 184 | } else { |
| 185 | /* |
| 186 | * thread is already done or waiting for fsync |
| 187 | */ |
| 188 | eta_sec = 0; |
| 189 | } |
| 190 | |
| 191 | return eta_sec; |
| 192 | } |
| 193 | |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 194 | static void calc_rate(unsigned long mtime, unsigned long long *io_bytes, |
| 195 | unsigned long long *prev_io_bytes, unsigned int *rate) |
| 196 | { |
| 197 | rate[0] = (io_bytes[0] - prev_io_bytes[0]) / mtime; |
| 198 | rate[1] = (io_bytes[1] - prev_io_bytes[1]) / mtime; |
| 199 | prev_io_bytes[0] = io_bytes[0]; |
| 200 | prev_io_bytes[1] = io_bytes[1]; |
| 201 | } |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 202 | |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 203 | static void calc_iops(unsigned long mtime, unsigned long long *io_iops, |
| 204 | unsigned long long *prev_io_iops, unsigned int *iops) |
| 205 | { |
| 206 | iops[0] = ((io_iops[0] - prev_io_iops[0]) * 1000) / mtime; |
| 207 | iops[1] = ((io_iops[1] - prev_io_iops[1]) * 1000) / mtime; |
| 208 | prev_io_iops[0] = io_iops[0]; |
| 209 | prev_io_iops[1] = io_iops[1]; |
| 210 | } |
| 211 | |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 212 | /* |
| 213 | * Print status of the jobs we know about. This includes rate estimates, |
| 214 | * ETA, thread state, etc. |
| 215 | */ |
| 216 | void print_thread_status(void) |
| 217 | { |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 218 | unsigned long elapsed = (mtime_since_genesis() + 999) / 1000; |
| 219 | int i, nr_ramp, nr_running, nr_pending, t_rate, m_rate; |
Jens Axboe | e6e4160 | 2007-03-27 20:20:36 +0200 | [diff] [blame] | 220 | int t_iops, m_iops, files_open; |
Jens Axboe | 34572e2 | 2006-10-20 09:33:18 +0200 | [diff] [blame] | 221 | struct thread_data *td; |
Jens Axboe | 2eaa41c | 2007-02-11 00:51:30 +0100 | [diff] [blame] | 222 | char eta_str[128]; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 223 | double perc = 0.0; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 224 | unsigned long long io_bytes[2], io_iops[2]; |
Jens Axboe | d3eeeab | 2008-04-06 12:19:05 +0200 | [diff] [blame] | 225 | unsigned long rate_time, disp_time, bw_avg_time, *eta_secs, eta_sec; |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 226 | struct timeval now; |
| 227 | |
| 228 | static unsigned long long rate_io_bytes[2]; |
| 229 | static unsigned long long disp_io_bytes[2]; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 230 | static unsigned long long disp_io_iops[2]; |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 231 | static struct timeval rate_prev_time, disp_prev_time; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 232 | static unsigned int rate[2], iops[2]; |
Aaron Carroll | 4381960 | 2007-10-26 11:10:28 +0200 | [diff] [blame] | 233 | static int linelen_last; |
Jens Axboe | cac58fd | 2008-06-06 01:17:03 +0200 | [diff] [blame] | 234 | static int eta_good; |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 235 | int i2p = 0; |
Jens Axboe | 6043c57 | 2006-11-03 11:37:47 +0100 | [diff] [blame] | 236 | |
Aaron Carroll | e592a06 | 2007-09-14 09:49:41 +0200 | [diff] [blame] | 237 | if (temp_stall_ts || terse_output || eta_print == FIO_ETA_NEVER) |
| 238 | return; |
| 239 | |
| 240 | if (!isatty(STDOUT_FILENO) && (eta_print != FIO_ETA_ALWAYS)) |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 241 | return; |
| 242 | |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 243 | if (!rate_io_bytes[0] && !rate_io_bytes[1]) |
| 244 | fill_start_time(&rate_prev_time); |
| 245 | if (!disp_io_bytes[0] && !disp_io_bytes[1]) |
| 246 | fill_start_time(&disp_prev_time); |
Jens Axboe | 6043c57 | 2006-11-03 11:37:47 +0100 | [diff] [blame] | 247 | |
Jens Axboe | d3eeeab | 2008-04-06 12:19:05 +0200 | [diff] [blame] | 248 | eta_secs = malloc(thread_number * sizeof(unsigned long)); |
| 249 | memset(eta_secs, 0, thread_number * sizeof(unsigned long)); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 250 | |
Jens Axboe | 6043c57 | 2006-11-03 11:37:47 +0100 | [diff] [blame] | 251 | io_bytes[0] = io_bytes[1] = 0; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 252 | io_iops[0] = io_iops[1] = 0; |
Jens Axboe | ac71feb | 2007-03-16 10:24:07 +0100 | [diff] [blame] | 253 | nr_pending = nr_running = t_rate = m_rate = t_iops = m_iops = 0; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 254 | nr_ramp = 0; |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 255 | bw_avg_time = ULONG_MAX; |
Jens Axboe | e6e4160 | 2007-03-27 20:20:36 +0200 | [diff] [blame] | 256 | files_open = 0; |
Jens Axboe | 34572e2 | 2006-10-20 09:33:18 +0200 | [diff] [blame] | 257 | for_each_td(td, i) { |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 258 | if (td->o.bw_avg_time < bw_avg_time) |
| 259 | bw_avg_time = td->o.bw_avg_time; |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 260 | if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING |
Jens Axboe | b0f6586 | 2009-05-20 11:52:15 +0200 | [diff] [blame] | 261 | || td->runstate == TD_FSYNCING |
| 262 | || td->runstate == TD_PRE_READING) { |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 263 | nr_running++; |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 264 | t_rate += td->o.rate[0] + td->o.rate[1]; |
| 265 | m_rate += td->o.ratemin[0] + td->o.ratemin[1]; |
| 266 | t_iops += td->o.rate_iops[0] + td->o.rate_iops[1]; |
| 267 | m_iops += td->o.rate_iops_min[0] + td->o.rate_iops_min[1]; |
Jens Axboe | e6e4160 | 2007-03-27 20:20:36 +0200 | [diff] [blame] | 268 | files_open += td->nr_open_files; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 269 | } else if (td->runstate == TD_RAMP) { |
| 270 | nr_running++; |
| 271 | nr_ramp++; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 272 | } else if (td->runstate < TD_RUNNING) |
| 273 | nr_pending++; |
| 274 | |
| 275 | if (elapsed >= 3) |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 276 | eta_secs[i] = thread_eta(td); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 277 | else |
| 278 | eta_secs[i] = INT_MAX; |
| 279 | |
| 280 | check_str_update(td); |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 281 | |
| 282 | if (td->runstate > TD_RAMP) { |
| 283 | io_bytes[0] += td->io_bytes[0]; |
| 284 | io_bytes[1] += td->io_bytes[1]; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 285 | io_iops[0] += td->io_blocks[0]; |
| 286 | io_iops[1] += td->io_blocks[1]; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 287 | } |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | if (exitall_on_terminate) |
| 291 | eta_sec = INT_MAX; |
| 292 | else |
| 293 | eta_sec = 0; |
| 294 | |
Jens Axboe | 34572e2 | 2006-10-20 09:33:18 +0200 | [diff] [blame] | 295 | for_each_td(td, i) { |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 296 | if (!i2p && is_power_of_2(td->o.kb_base)) |
| 297 | i2p = 1; |
Shaozhi Shawn Ye | 9c5a385 | 2008-09-10 09:09:37 +0200 | [diff] [blame] | 298 | if (exitall_on_terminate) { |
| 299 | if (eta_secs[i] < eta_sec) |
| 300 | eta_sec = eta_secs[i]; |
| 301 | } else { |
| 302 | if (eta_secs[i] > eta_sec) |
| 303 | eta_sec = eta_secs[i]; |
| 304 | } |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 305 | } |
| 306 | |
Jens Axboe | eecf272 | 2006-10-20 14:00:36 +0200 | [diff] [blame] | 307 | free(eta_secs); |
| 308 | |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 309 | if (eta_sec != INT_MAX && elapsed) { |
| 310 | perc = (double) elapsed / (double) (elapsed + eta_sec); |
| 311 | eta_to_str(eta_str, eta_sec); |
| 312 | } |
| 313 | |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 314 | fio_gettime(&now, NULL); |
| 315 | rate_time = mtime_since(&rate_prev_time, &now); |
| 316 | |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 317 | if (write_bw_log && rate_time > bw_avg_time && !in_ramp_time(td)) { |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 318 | calc_rate(rate_time, io_bytes, rate_io_bytes, rate); |
| 319 | memcpy(&rate_prev_time, &now, sizeof(now)); |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 320 | add_agg_sample(rate[DDIR_READ], DDIR_READ, 0); |
| 321 | add_agg_sample(rate[DDIR_WRITE], DDIR_WRITE, 0); |
Jens Axboe | 6043c57 | 2006-11-03 11:37:47 +0100 | [diff] [blame] | 322 | } |
| 323 | |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 324 | disp_time = mtime_since(&disp_prev_time, &now); |
| 325 | if (disp_time < 1000) |
| 326 | return; |
| 327 | |
| 328 | calc_rate(disp_time, io_bytes, disp_io_bytes, rate); |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 329 | calc_iops(disp_time, io_iops, disp_io_iops, iops); |
| 330 | |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 331 | memcpy(&disp_prev_time, &now, sizeof(now)); |
| 332 | |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 333 | if (!nr_running && !nr_pending) |
| 334 | return; |
| 335 | |
Jens Axboe | e6e4160 | 2007-03-27 20:20:36 +0200 | [diff] [blame] | 336 | printf("Jobs: %d (f=%d)", nr_running, files_open); |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 337 | if (m_rate || t_rate) { |
| 338 | char *tr, *mr; |
| 339 | |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 340 | mr = num2str(m_rate, 4, 0, i2p); |
| 341 | tr = num2str(t_rate, 4, 0, i2p); |
Jens Axboe | b22989b | 2009-07-17 22:29:23 +0200 | [diff] [blame] | 342 | printf(", CR=%s/%s KB/s", tr, mr); |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 343 | free(tr); |
| 344 | free(mr); |
| 345 | } else if (m_iops || t_iops) |
Jens Axboe | ac71feb | 2007-03-16 10:24:07 +0100 | [diff] [blame] | 346 | printf(", CR=%d/%d IOPS", t_iops, m_iops); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 347 | if (eta_sec != INT_MAX && nr_running) { |
Jens Axboe | 0721d11 | 2008-06-05 09:03:05 +0200 | [diff] [blame] | 348 | char perc_str[32]; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 349 | char *iops_str[2]; |
Jens Axboe | d1bd721 | 2009-06-03 10:53:45 +0200 | [diff] [blame] | 350 | char *rate_str[2]; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 351 | int l; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 352 | |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 353 | if ((!eta_sec && !eta_good) || nr_ramp == nr_running) |
Jens Axboe | cac58fd | 2008-06-06 01:17:03 +0200 | [diff] [blame] | 354 | strcpy(perc_str, "-.-% done"); |
| 355 | else { |
| 356 | eta_good = 1; |
| 357 | perc *= 100.0; |
Jens Axboe | 0721d11 | 2008-06-05 09:03:05 +0200 | [diff] [blame] | 358 | sprintf(perc_str, "%3.1f%% done", perc); |
Jens Axboe | cac58fd | 2008-06-06 01:17:03 +0200 | [diff] [blame] | 359 | } |
Jens Axboe | 0721d11 | 2008-06-05 09:03:05 +0200 | [diff] [blame] | 360 | |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 361 | rate_str[0] = num2str(rate[0], 5, 10, i2p); |
| 362 | rate_str[1] = num2str(rate[1], 5, 10, i2p); |
Jens Axboe | d1bd721 | 2009-06-03 10:53:45 +0200 | [diff] [blame] | 363 | |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 364 | iops_str[0] = num2str(iops[0], 4, 1, 0); |
| 365 | iops_str[1] = num2str(iops[1], 4, 1, 0); |
| 366 | |
Jens Axboe | d1bd721 | 2009-06-03 10:53:45 +0200 | [diff] [blame] | 367 | l = printf(": [%s] [%s] [%s/%s /s] [%s/%s iops] [eta %s]", |
| 368 | run_str, perc_str, rate_str[0], rate_str[1], |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 369 | iops_str[0], iops_str[1], eta_str); |
| 370 | if (l >= 0 && l < linelen_last) |
| 371 | printf("%*s", linelen_last - l, ""); |
| 372 | linelen_last = l; |
Jens Axboe | d1bd721 | 2009-06-03 10:53:45 +0200 | [diff] [blame] | 373 | |
| 374 | free(rate_str[0]); |
| 375 | free(rate_str[1]); |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 376 | free(iops_str[0]); |
| 377 | free(iops_str[1]); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 378 | } |
| 379 | printf("\r"); |
| 380 | fflush(stdout); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | void print_status_init(int thread_number) |
| 384 | { |
| 385 | run_str[thread_number] = 'P'; |
| 386 | } |