blob: 0833d3412450a6ddd788369cf2c064f41918ef34 [file] [log] [blame]
Jens Axboe263e5292006-10-18 15:37:01 +02001/*
2 * Status and ETA code
3 */
4#include <unistd.h>
5#include <fcntl.h>
6#include <string.h>
7
8#include "fio.h"
Jens Axboe263e5292006-10-18 15:37:01 +02009
Stephen M. Cameronba936c42012-02-24 08:17:31 +010010void (*update_thread_status)(char *status_message) = NULL;
11
Jens Axboefca70352011-07-06 20:12:54 +020012static char run_str[REAL_MAX_JOBS + 1];
Jens Axboe263e5292006-10-18 15:37:01 +020013
14/*
15 * Sets the status of the 'td' in the printed status map.
16 */
17static void check_str_update(struct thread_data *td)
18{
19 char c = run_str[td->thread_number - 1];
20
21 switch (td->runstate) {
Jens Axboe5ec10ea2008-03-06 15:42:00 +010022 case TD_REAPED:
23 c = '_';
24 break;
25 case TD_EXITED:
26 c = 'E';
27 break;
Jens Axboeb29ee5b2008-09-11 10:17:26 +020028 case TD_RAMP:
29 c = '/';
30 break;
Jens Axboe5ec10ea2008-03-06 15:42:00 +010031 case TD_RUNNING:
32 if (td_rw(td)) {
Jens Axboee3b3f812011-09-01 09:58:11 -060033 if (td_random(td)) {
34 if (td->o.rwmix[DDIR_READ] == 100)
35 c = 'r';
36 else if (td->o.rwmix[DDIR_WRITE] == 100)
37 c = 'w';
38 else
39 c = 'm';
40 } else {
41 if (td->o.rwmix[DDIR_READ] == 100)
42 c = 'R';
43 else if (td->o.rwmix[DDIR_WRITE] == 100)
44 c = 'W';
45 else
46 c = 'M';
47 }
Jens Axboe5ec10ea2008-03-06 15:42:00 +010048 } else if (td_read(td)) {
49 if (td_random(td))
50 c = 'r';
51 else
52 c = 'R';
53 } else {
54 if (td_random(td))
55 c = 'w';
56 else
57 c = 'W';
58 }
59 break;
Jens Axboeb0f65862009-05-20 11:52:15 +020060 case TD_PRE_READING:
61 c = 'p';
62 break;
Jens Axboe5ec10ea2008-03-06 15:42:00 +010063 case TD_VERIFYING:
64 c = 'V';
65 break;
66 case TD_FSYNCING:
67 c = 'F';
68 break;
69 case TD_CREATED:
70 c = 'C';
71 break;
72 case TD_INITIALIZED:
73 c = 'I';
74 break;
75 case TD_NOT_CREATED:
76 c = 'P';
77 break;
78 default:
79 log_err("state %d\n", td->runstate);
Jens Axboe263e5292006-10-18 15:37:01 +020080 }
81
82 run_str[td->thread_number - 1] = c;
83}
84
85/*
86 * Convert seconds to a printable string.
87 */
Gurudas Pai9c02f6e2008-06-13 08:40:11 +020088static void eta_to_str(char *str, unsigned long eta_sec)
Jens Axboe263e5292006-10-18 15:37:01 +020089{
90 unsigned int d, h, m, s;
Jens Axboe165faf12007-02-07 11:30:37 +010091 int disp_hour = 0;
Jens Axboe263e5292006-10-18 15:37:01 +020092
Jens Axboe263e5292006-10-18 15:37:01 +020093 s = eta_sec % 60;
94 eta_sec /= 60;
95 m = eta_sec % 60;
96 eta_sec /= 60;
97 h = eta_sec % 24;
98 eta_sec /= 24;
99 d = eta_sec;
100
Jens Axboe165faf12007-02-07 11:30:37 +0100101 if (d) {
102 disp_hour = 1;
Jens Axboe1e97cce2006-12-05 11:44:16 +0100103 str += sprintf(str, "%02ud:", d);
Jens Axboe263e5292006-10-18 15:37:01 +0200104 }
Jens Axboe165faf12007-02-07 11:30:37 +0100105
106 if (h || disp_hour)
Jens Axboe1e97cce2006-12-05 11:44:16 +0100107 str += sprintf(str, "%02uh:", h);
Jens Axboe263e5292006-10-18 15:37:01 +0200108
Jens Axboe1e97cce2006-12-05 11:44:16 +0100109 str += sprintf(str, "%02um:", m);
110 str += sprintf(str, "%02us", s);
Jens Axboe263e5292006-10-18 15:37:01 +0200111}
112
113/*
114 * Best effort calculation of the estimated pending runtime of a job.
115 */
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200116static int thread_eta(struct thread_data *td)
Jens Axboe263e5292006-10-18 15:37:01 +0200117{
118 unsigned long long bytes_total, bytes_done;
Jens Axboe1e97cce2006-12-05 11:44:16 +0100119 unsigned long eta_sec = 0;
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200120 unsigned long elapsed;
121
122 elapsed = (mtime_since_now(&td->epoch) + 999) / 1000;
Jens Axboe263e5292006-10-18 15:37:01 +0200123
124 bytes_total = td->total_io_size;
125
Jens Axboe2e3bd4c2010-05-17 12:29:57 +0200126 if (td->o.fill_device && td->o.size == -1ULL) {
127 if (!td->fill_device_size || td->fill_device_size == -1ULL)
128 return 0;
129
130 bytes_total = td->fill_device_size;
131 }
132
Jens Axboe74939e32006-10-19 20:37:12 +0200133 /*
134 * if writing, bytes_total will be twice the size. If mixing,
135 * assume a 50/50 split and thus bytes_total will be 50% larger.
136 */
Jens Axboe0dd83772007-09-04 12:38:28 +0200137 if (td->o.do_verify && td->o.verify && td_write(td)) {
Jens Axboe74939e32006-10-19 20:37:12 +0200138 if (td_rw(td))
139 bytes_total = bytes_total * 3 / 2;
140 else
141 bytes_total <<= 1;
142 }
143
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100144 if (td->o.zone_size && td->o.zone_skip)
145 bytes_total /= (td->o.zone_skip / td->o.zone_size);
Jens Axboe263e5292006-10-18 15:37:01 +0200146
147 if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) {
Jens Axboecf4464c2007-04-17 20:14:42 +0200148 double perc, perc_t;
Jens Axboe263e5292006-10-18 15:37:01 +0200149
150 bytes_done = td->io_bytes[DDIR_READ] + td->io_bytes[DDIR_WRITE];
151 perc = (double) bytes_done / (double) bytes_total;
152 if (perc > 1.0)
153 perc = 1.0;
154
Jens Axboecf4464c2007-04-17 20:14:42 +0200155 if (td->o.time_based) {
156 perc_t = (double) elapsed / (double) td->o.timeout;
157 if (perc_t < perc)
158 perc = perc_t;
159 }
160
Jens Axboe1e97cce2006-12-05 11:44:16 +0100161 eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
Jens Axboe263e5292006-10-18 15:37:01 +0200162
Jens Axboed3eeeab2008-04-06 12:19:05 +0200163 if (td->o.timeout &&
164 eta_sec > (td->o.timeout + done_secs - elapsed))
165 eta_sec = td->o.timeout + done_secs - elapsed;
Jens Axboe263e5292006-10-18 15:37:01 +0200166 } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200167 || td->runstate == TD_INITIALIZED
Jens Axboeb0f65862009-05-20 11:52:15 +0200168 || td->runstate == TD_RAMP
169 || td->runstate == TD_PRE_READING) {
Jens Axboe263e5292006-10-18 15:37:01 +0200170 int t_eta = 0, r_eta = 0;
171
172 /*
173 * We can only guess - assume it'll run the full timeout
174 * if given, otherwise assume it'll run at the specified rate.
175 */
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200176 if (td->o.timeout) {
Signed-off-by Steven Prattcda99fa2010-12-14 08:31:36 +0100177 t_eta = td->o.timeout + td->o.start_delay +
178 td->o.ramp_time;
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200179
180 if (in_ramp_time(td)) {
181 unsigned long ramp_left;
182
Signed-off-by Steven Prattcda99fa2010-12-14 08:31:36 +0100183 ramp_left = mtime_since_now(&td->epoch);
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200184 ramp_left = (ramp_left + 999) / 1000;
185 if (ramp_left <= t_eta)
186 t_eta -= ramp_left;
187 }
188 }
Jens Axboe581e7142009-06-09 12:47:16 +0200189 if (td->o.rate[0] || td->o.rate[1]) {
Jens Axboe0b9d69e2009-09-11 22:29:54 +0200190 r_eta = (bytes_total / 1024) /
191 (td->o.rate[0] + td->o.rate[1]);
Jens Axboed3eeeab2008-04-06 12:19:05 +0200192 r_eta += td->o.start_delay;
Jens Axboe263e5292006-10-18 15:37:01 +0200193 }
194
195 if (r_eta && t_eta)
196 eta_sec = min(r_eta, t_eta);
197 else if (r_eta)
198 eta_sec = r_eta;
199 else if (t_eta)
200 eta_sec = t_eta;
201 else
202 eta_sec = 0;
203 } else {
204 /*
205 * thread is already done or waiting for fsync
206 */
207 eta_sec = 0;
208 }
209
210 return eta_sec;
211}
212
Jens Axboe46fda8d2007-02-11 00:49:30 +0100213static void calc_rate(unsigned long mtime, unsigned long long *io_bytes,
214 unsigned long long *prev_io_bytes, unsigned int *rate)
215{
216 rate[0] = (io_bytes[0] - prev_io_bytes[0]) / mtime;
217 rate[1] = (io_bytes[1] - prev_io_bytes[1]) / mtime;
218 prev_io_bytes[0] = io_bytes[0];
219 prev_io_bytes[1] = io_bytes[1];
220}
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100221
Jens Axboeadb02ba2009-06-03 10:47:44 +0200222static void calc_iops(unsigned long mtime, unsigned long long *io_iops,
223 unsigned long long *prev_io_iops, unsigned int *iops)
224{
225 iops[0] = ((io_iops[0] - prev_io_iops[0]) * 1000) / mtime;
226 iops[1] = ((io_iops[1] - prev_io_iops[1]) * 1000) / mtime;
227 prev_io_iops[0] = io_iops[0];
228 prev_io_iops[1] = io_iops[1];
229}
230
Jens Axboe263e5292006-10-18 15:37:01 +0200231/*
232 * Print status of the jobs we know about. This includes rate estimates,
233 * ETA, thread state, etc.
234 */
Jens Axboeaf9c9fb2011-10-09 21:54:10 +0200235int calc_thread_status(struct jobs_eta *je, int force)
Jens Axboe263e5292006-10-18 15:37:01 +0200236{
Jens Axboe34572e22006-10-20 09:33:18 +0200237 struct thread_data *td;
Jens Axboeb75a3942011-10-03 16:03:43 +0200238 int i;
239 unsigned long rate_time, disp_time, bw_avg_time, *eta_secs;
240 unsigned long long io_bytes[2];
241 unsigned long long io_iops[2];
Jens Axboe46fda8d2007-02-11 00:49:30 +0100242 struct timeval now;
243
244 static unsigned long long rate_io_bytes[2];
245 static unsigned long long disp_io_bytes[2];
Jens Axboeadb02ba2009-06-03 10:47:44 +0200246 static unsigned long long disp_io_iops[2];
Jens Axboe46fda8d2007-02-11 00:49:30 +0100247 static struct timeval rate_prev_time, disp_prev_time;
Jens Axboed6978a32009-07-18 21:04:09 +0200248 int i2p = 0;
Jens Axboe6043c572006-11-03 11:37:47 +0100249
Jens Axboeaf9c9fb2011-10-09 21:54:10 +0200250 if (!force) {
251 if (temp_stall_ts || terse_output || eta_print == FIO_ETA_NEVER)
252 return 0;
Aaron Carrolle592a062007-09-14 09:49:41 +0200253
Jens Axboeaf9c9fb2011-10-09 21:54:10 +0200254 if (!isatty(STDOUT_FILENO) && (eta_print != FIO_ETA_ALWAYS))
255 return 0;
256 }
Jens Axboe263e5292006-10-18 15:37:01 +0200257
Jens Axboe46fda8d2007-02-11 00:49:30 +0100258 if (!rate_io_bytes[0] && !rate_io_bytes[1])
259 fill_start_time(&rate_prev_time);
260 if (!disp_io_bytes[0] && !disp_io_bytes[1])
261 fill_start_time(&disp_prev_time);
Jens Axboe6043c572006-11-03 11:37:47 +0100262
Jens Axboed3eeeab2008-04-06 12:19:05 +0200263 eta_secs = malloc(thread_number * sizeof(unsigned long));
264 memset(eta_secs, 0, thread_number * sizeof(unsigned long));
Jens Axboe263e5292006-10-18 15:37:01 +0200265
Jens Axboeb75a3942011-10-03 16:03:43 +0200266 je->elapsed_sec = (mtime_since_genesis() + 999) / 1000;
267
Jens Axboe6043c572006-11-03 11:37:47 +0100268 io_bytes[0] = io_bytes[1] = 0;
Jens Axboeadb02ba2009-06-03 10:47:44 +0200269 io_iops[0] = io_iops[1] = 0;
Jens Axboebb3884d2007-01-17 17:23:11 +1100270 bw_avg_time = ULONG_MAX;
Jens Axboe34572e22006-10-20 09:33:18 +0200271 for_each_td(td, i) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100272 if (td->o.bw_avg_time < bw_avg_time)
273 bw_avg_time = td->o.bw_avg_time;
Jens Axboe46fda8d2007-02-11 00:49:30 +0100274 if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING
Jens Axboeb0f65862009-05-20 11:52:15 +0200275 || td->runstate == TD_FSYNCING
276 || td->runstate == TD_PRE_READING) {
Jens Axboeb75a3942011-10-03 16:03:43 +0200277 je->nr_running++;
278 je->t_rate += td->o.rate[0] + td->o.rate[1];
279 je->m_rate += td->o.ratemin[0] + td->o.ratemin[1];
280 je->t_iops += td->o.rate_iops[0] + td->o.rate_iops[1];
281 je->m_iops += td->o.rate_iops_min[0] +
Jens Axboe0b9d69e2009-09-11 22:29:54 +0200282 td->o.rate_iops_min[1];
Jens Axboeb75a3942011-10-03 16:03:43 +0200283 je->files_open += td->nr_open_files;
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200284 } else if (td->runstate == TD_RAMP) {
Jens Axboeb75a3942011-10-03 16:03:43 +0200285 je->nr_running++;
286 je->nr_ramp++;
Jens Axboe263e5292006-10-18 15:37:01 +0200287 } else if (td->runstate < TD_RUNNING)
Jens Axboeb75a3942011-10-03 16:03:43 +0200288 je->nr_pending++;
Jens Axboe263e5292006-10-18 15:37:01 +0200289
Jens Axboeb75a3942011-10-03 16:03:43 +0200290 if (je->elapsed_sec >= 3)
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200291 eta_secs[i] = thread_eta(td);
Jens Axboe263e5292006-10-18 15:37:01 +0200292 else
293 eta_secs[i] = INT_MAX;
294
295 check_str_update(td);
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200296
297 if (td->runstate > TD_RAMP) {
298 io_bytes[0] += td->io_bytes[0];
299 io_bytes[1] += td->io_bytes[1];
Jens Axboeadb02ba2009-06-03 10:47:44 +0200300 io_iops[0] += td->io_blocks[0];
301 io_iops[1] += td->io_blocks[1];
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200302 }
Jens Axboe263e5292006-10-18 15:37:01 +0200303 }
304
305 if (exitall_on_terminate)
Jens Axboeb75a3942011-10-03 16:03:43 +0200306 je->eta_sec = INT_MAX;
Jens Axboe263e5292006-10-18 15:37:01 +0200307 else
Jens Axboeb75a3942011-10-03 16:03:43 +0200308 je->eta_sec = 0;
Jens Axboe263e5292006-10-18 15:37:01 +0200309
Jens Axboe34572e22006-10-20 09:33:18 +0200310 for_each_td(td, i) {
Jens Axboed6978a32009-07-18 21:04:09 +0200311 if (!i2p && is_power_of_2(td->o.kb_base))
312 i2p = 1;
Shaozhi Shawn Ye9c5a3852008-09-10 09:09:37 +0200313 if (exitall_on_terminate) {
Jens Axboeb75a3942011-10-03 16:03:43 +0200314 if (eta_secs[i] < je->eta_sec)
315 je->eta_sec = eta_secs[i];
Shaozhi Shawn Ye9c5a3852008-09-10 09:09:37 +0200316 } else {
Jens Axboeb75a3942011-10-03 16:03:43 +0200317 if (eta_secs[i] > je->eta_sec)
318 je->eta_sec = eta_secs[i];
Shaozhi Shawn Ye9c5a3852008-09-10 09:09:37 +0200319 }
Jens Axboe263e5292006-10-18 15:37:01 +0200320 }
321
Jens Axboeeecf2722006-10-20 14:00:36 +0200322 free(eta_secs);
323
Jens Axboe46fda8d2007-02-11 00:49:30 +0100324 fio_gettime(&now, NULL);
325 rate_time = mtime_since(&rate_prev_time, &now);
326
Jens Axboeb29ee5b2008-09-11 10:17:26 +0200327 if (write_bw_log && rate_time > bw_avg_time && !in_ramp_time(td)) {
Jens Axboeb75a3942011-10-03 16:03:43 +0200328 calc_rate(rate_time, io_bytes, rate_io_bytes, je->rate);
Jens Axboe46fda8d2007-02-11 00:49:30 +0100329 memcpy(&rate_prev_time, &now, sizeof(now));
Jens Axboeb75a3942011-10-03 16:03:43 +0200330 add_agg_sample(je->rate[DDIR_READ], DDIR_READ, 0);
331 add_agg_sample(je->rate[DDIR_WRITE], DDIR_WRITE, 0);
Jens Axboe6043c572006-11-03 11:37:47 +0100332 }
333
Jens Axboe46fda8d2007-02-11 00:49:30 +0100334 disp_time = mtime_since(&disp_prev_time, &now);
Jens Axboea5b01f12010-11-11 09:19:49 +0100335
336 /*
337 * Allow a little slack, the target is to print it every 1000 msecs
338 */
Jens Axboeaf9c9fb2011-10-09 21:54:10 +0200339 if (!force && disp_time < 900)
Jens Axboeb75a3942011-10-03 16:03:43 +0200340 return 0;
Jens Axboe46fda8d2007-02-11 00:49:30 +0100341
Jens Axboeb75a3942011-10-03 16:03:43 +0200342 calc_rate(disp_time, io_bytes, disp_io_bytes, je->rate);
343 calc_iops(disp_time, io_iops, disp_io_iops, je->iops);
Jens Axboeadb02ba2009-06-03 10:47:44 +0200344
Jens Axboe46fda8d2007-02-11 00:49:30 +0100345 memcpy(&disp_prev_time, &now, sizeof(now));
346
Jens Axboeaf9c9fb2011-10-09 21:54:10 +0200347 if (!force && !je->nr_running && !je->nr_pending)
Jens Axboeb75a3942011-10-03 16:03:43 +0200348 return 0;
349
Jens Axboe1d1f45a2011-10-03 19:44:41 +0200350 je->nr_threads = thread_number;
351 memcpy(je->run_str, run_str, thread_number * sizeof(char));
352
Jens Axboeb75a3942011-10-03 16:03:43 +0200353 return 1;
354}
355
Jens Axboecf451d12011-10-03 16:48:30 +0200356void display_thread_status(struct jobs_eta *je)
Jens Axboeb75a3942011-10-03 16:03:43 +0200357{
Jens Axboeb75a3942011-10-03 16:03:43 +0200358 static int linelen_last;
359 static int eta_good;
360 char output[512], *p = output;
361 char eta_str[128];
362 double perc = 0.0;
363 int i2p = 0;
364
Jens Axboecf451d12011-10-03 16:48:30 +0200365 if (je->eta_sec != INT_MAX && je->elapsed_sec) {
366 perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec);
367 eta_to_str(eta_str, je->eta_sec);
Jens Axboeb75a3942011-10-03 16:03:43 +0200368 }
369
Jens Axboecf451d12011-10-03 16:48:30 +0200370 p += sprintf(p, "Jobs: %d (f=%d)", je->nr_running, je->files_open);
371 if (je->m_rate || je->t_rate) {
Jens Axboe581e7142009-06-09 12:47:16 +0200372 char *tr, *mr;
373
Jens Axboecf451d12011-10-03 16:48:30 +0200374 mr = num2str(je->m_rate, 4, 0, i2p);
375 tr = num2str(je->t_rate, 4, 0, i2p);
Jens Axboe37db14f2011-09-30 17:00:42 -0600376 p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
Jens Axboe581e7142009-06-09 12:47:16 +0200377 free(tr);
378 free(mr);
Jens Axboecf451d12011-10-03 16:48:30 +0200379 } else if (je->m_iops || je->t_iops)
380 p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops);
381 if (je->eta_sec != INT_MAX && je->nr_running) {
Jens Axboe0721d112008-06-05 09:03:05 +0200382 char perc_str[32];
Jens Axboeadb02ba2009-06-03 10:47:44 +0200383 char *iops_str[2];
Jens Axboed1bd7212009-06-03 10:53:45 +0200384 char *rate_str[2];
Jens Axboeadb02ba2009-06-03 10:47:44 +0200385 int l;
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100386
Jens Axboecf451d12011-10-03 16:48:30 +0200387 if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running)
Jens Axboecac58fd2008-06-06 01:17:03 +0200388 strcpy(perc_str, "-.-% done");
389 else {
390 eta_good = 1;
391 perc *= 100.0;
Jens Axboe0721d112008-06-05 09:03:05 +0200392 sprintf(perc_str, "%3.1f%% done", perc);
Jens Axboecac58fd2008-06-06 01:17:03 +0200393 }
Jens Axboe0721d112008-06-05 09:03:05 +0200394
Jens Axboecf451d12011-10-03 16:48:30 +0200395 rate_str[0] = num2str(je->rate[0], 5, 10, i2p);
396 rate_str[1] = num2str(je->rate[1], 5, 10, i2p);
Jens Axboed1bd7212009-06-03 10:53:45 +0200397
Jens Axboecf451d12011-10-03 16:48:30 +0200398 iops_str[0] = num2str(je->iops[0], 4, 1, 0);
399 iops_str[1] = num2str(je->iops[1], 4, 1, 0);
Jens Axboeadb02ba2009-06-03 10:47:44 +0200400
Jens Axboe37db14f2011-09-30 17:00:42 -0600401 l = sprintf(p, ": [%s] [%s] [%s/%s /s] [%s/%s iops] [eta %s]",
Jens Axboe1d1f45a2011-10-03 19:44:41 +0200402 je->run_str, perc_str, rate_str[0],
403 rate_str[1], iops_str[0], iops_str[1], eta_str);
Jens Axboe37db14f2011-09-30 17:00:42 -0600404 p += l;
Jens Axboeadb02ba2009-06-03 10:47:44 +0200405 if (l >= 0 && l < linelen_last)
Jens Axboe37db14f2011-09-30 17:00:42 -0600406 p += sprintf(p, "%*s", linelen_last - l, "");
Jens Axboeadb02ba2009-06-03 10:47:44 +0200407 linelen_last = l;
Jens Axboed1bd7212009-06-03 10:53:45 +0200408
409 free(rate_str[0]);
410 free(rate_str[1]);
Jens Axboeadb02ba2009-06-03 10:47:44 +0200411 free(iops_str[0]);
412 free(iops_str[1]);
Jens Axboe263e5292006-10-18 15:37:01 +0200413 }
Jens Axboe37db14f2011-09-30 17:00:42 -0600414 p += sprintf(p, "\r");
415
Stephen M. Cameronba936c42012-02-24 08:17:31 +0100416 if (update_thread_status) {
417 update_thread_status(output);
418 } else {
419 printf("%s", output);
420 fflush(stdout);
421 }
Jens Axboe263e5292006-10-18 15:37:01 +0200422}
423
Jens Axboecf451d12011-10-03 16:48:30 +0200424void print_thread_status(void)
425{
Jens Axboe1d1f45a2011-10-03 19:44:41 +0200426 struct jobs_eta *je;
Jens Axboeb814fb22011-10-12 09:20:34 +0200427 size_t size;
Jens Axboecf451d12011-10-03 16:48:30 +0200428
Jens Axboeb814fb22011-10-12 09:20:34 +0200429 if (!thread_number)
430 return;
Jens Axboecf451d12011-10-03 16:48:30 +0200431
Jens Axboeb814fb22011-10-12 09:20:34 +0200432 size = sizeof(*je) + thread_number * sizeof(char) + 1;
433 je = malloc(size);
434 memset(je, 0, size);
Jens Axboecf451d12011-10-03 16:48:30 +0200435
Jens Axboeaf9c9fb2011-10-09 21:54:10 +0200436 if (calc_thread_status(je, 0))
Jens Axboe1d1f45a2011-10-03 19:44:41 +0200437 display_thread_status(je);
438
439 free(je);
Jens Axboecf451d12011-10-03 16:48:30 +0200440}
Jens Axboeb75a3942011-10-03 16:03:43 +0200441
Jens Axboe2b13e712011-01-19 14:04:16 -0700442void print_status_init(int thr_number)
Jens Axboe263e5292006-10-18 15:37:01 +0200443{
Jens Axboe2b13e712011-01-19 14:04:16 -0700444 run_str[thr_number] = 'P';
Jens Axboe263e5292006-10-18 15:37:01 +0200445}