Add string condensing for the ETA output
[fio.git] / eta.c
CommitLineData
263e529f
JA
1/*
2 * Status and ETA code
3 */
4#include <unistd.h>
5#include <fcntl.h>
6#include <string.h>
7
8#include "fio.h"
263e529f 9
3e2e48a7
JA
10static char __run_str[REAL_MAX_JOBS + 1];
11
12/*
13 * Worst level condensing would be 1:4, so allow enough room for that
14 */
15static char run_str[(4 * REAL_MAX_JOBS) + 1];
16
17static void update_condensed_str(char *run_str, char *run_str_condensed)
18{
19 int i, ci, last, nr;
20 size_t len;
21
22 len = strlen(run_str);
23 if (!len)
24 return;
25
26 last = 0;
27 nr = 0;
28 ci = 0;
29 for (i = 0; i < len; i++) {
30 if (!last) {
31new:
32 run_str_condensed[ci] = run_str[i];
33 last = run_str[i];
34 nr = 1;
35 ci++;
36 } else if (last == run_str[i]) {
37 nr++;
38 } else {
39 int elen;
40
41 elen = sprintf(&run_str_condensed[ci], "(%u),", nr);
42 ci += elen;
43 goto new;
44 }
45 }
46
47 if (nr)
48 sprintf(&run_str_condensed[ci], "(%u)", nr);
49}
50
263e529f
JA
51
52/*
53 * Sets the status of the 'td' in the printed status map.
54 */
55static void check_str_update(struct thread_data *td)
56{
3e2e48a7 57 char c = __run_str[td->thread_number - 1];
263e529f
JA
58
59 switch (td->runstate) {
5ec10eaa 60 case TD_REAPED:
4f7e57a4
JA
61 if (td->error)
62 c = 'X';
a5e371a6
JA
63 else if (td->sig)
64 c = 'K';
4f7e57a4
JA
65 else
66 c = '_';
5ec10eaa
JA
67 break;
68 case TD_EXITED:
69 c = 'E';
70 break;
b29ee5b3
JA
71 case TD_RAMP:
72 c = '/';
73 break;
5ec10eaa
JA
74 case TD_RUNNING:
75 if (td_rw(td)) {
e3b3f81e
JA
76 if (td_random(td)) {
77 if (td->o.rwmix[DDIR_READ] == 100)
78 c = 'r';
79 else if (td->o.rwmix[DDIR_WRITE] == 100)
80 c = 'w';
81 else
82 c = 'm';
83 } else {
84 if (td->o.rwmix[DDIR_READ] == 100)
85 c = 'R';
86 else if (td->o.rwmix[DDIR_WRITE] == 100)
87 c = 'W';
88 else
89 c = 'M';
90 }
5ec10eaa
JA
91 } else if (td_read(td)) {
92 if (td_random(td))
93 c = 'r';
94 else
95 c = 'R';
6eaf09d6 96 } else if (td_write(td)) {
5ec10eaa
JA
97 if (td_random(td))
98 c = 'w';
99 else
100 c = 'W';
6eaf09d6
SL
101 } else {
102 if (td_random(td))
103 c = 'd';
104 else
105 c = 'D';
5ec10eaa
JA
106 }
107 break;
b0f65863
JA
108 case TD_PRE_READING:
109 c = 'p';
110 break;
5ec10eaa
JA
111 case TD_VERIFYING:
112 c = 'V';
113 break;
114 case TD_FSYNCING:
115 c = 'F';
116 break;
3d434057
JA
117 case TD_FINISHING:
118 c = 'f';
119 break;
5ec10eaa
JA
120 case TD_CREATED:
121 c = 'C';
122 break;
123 case TD_INITIALIZED:
9c6f6316 124 case TD_SETTING_UP:
5ec10eaa
JA
125 c = 'I';
126 break;
127 case TD_NOT_CREATED:
128 c = 'P';
129 break;
130 default:
131 log_err("state %d\n", td->runstate);
263e529f
JA
132 }
133
3e2e48a7
JA
134 __run_str[td->thread_number - 1] = c;
135 update_condensed_str(__run_str, run_str);
263e529f
JA
136}
137
138/*
139 * Convert seconds to a printable string.
140 */
3e47bd25 141void eta_to_str(char *str, unsigned long eta_sec)
263e529f
JA
142{
143 unsigned int d, h, m, s;
165faf16 144 int disp_hour = 0;
263e529f 145
263e529f
JA
146 s = eta_sec % 60;
147 eta_sec /= 60;
148 m = eta_sec % 60;
149 eta_sec /= 60;
150 h = eta_sec % 24;
151 eta_sec /= 24;
152 d = eta_sec;
153
165faf16
JA
154 if (d) {
155 disp_hour = 1;
1e97cce9 156 str += sprintf(str, "%02ud:", d);
263e529f 157 }
165faf16
JA
158
159 if (h || disp_hour)
1e97cce9 160 str += sprintf(str, "%02uh:", h);
263e529f 161
1e97cce9
JA
162 str += sprintf(str, "%02um:", m);
163 str += sprintf(str, "%02us", s);
263e529f
JA
164}
165
166/*
167 * Best effort calculation of the estimated pending runtime of a job.
168 */
b29ee5b3 169static int thread_eta(struct thread_data *td)
263e529f
JA
170{
171 unsigned long long bytes_total, bytes_done;
1e97cce9 172 unsigned long eta_sec = 0;
b29ee5b3 173 unsigned long elapsed;
0de5b26f 174 uint64_t timeout;
b29ee5b3
JA
175
176 elapsed = (mtime_since_now(&td->epoch) + 999) / 1000;
0de5b26f 177 timeout = td->o.timeout / 1000000UL;
263e529f
JA
178
179 bytes_total = td->total_io_size;
180
2e3bd4c2
JA
181 if (td->o.fill_device && td->o.size == -1ULL) {
182 if (!td->fill_device_size || td->fill_device_size == -1ULL)
183 return 0;
184
185 bytes_total = td->fill_device_size;
186 }
187
0d73a2f9
JA
188 if (td->o.zone_size && td->o.zone_skip && bytes_total) {
189 unsigned int nr_zones;
190 uint64_t zone_bytes;
191
192 zone_bytes = bytes_total + td->o.zone_size + td->o.zone_skip;
193 nr_zones = (zone_bytes - 1) / (td->o.zone_size + td->o.zone_skip);
194 bytes_total -= nr_zones * td->o.zone_skip;
195 }
196
74939e38 197 /*
165eb050
JA
198 * if writing and verifying afterwards, bytes_total will be twice the
199 * size. In a mixed workload, verify phase will be the size of the
200 * first stage writes.
74939e38 201 */
0dd8377f 202 if (td->o.do_verify && td->o.verify && td_write(td)) {
165eb050
JA
203 if (td_rw(td)) {
204 unsigned int perc = 50;
205
206 if (td->o.rwmix[DDIR_WRITE])
207 perc = td->o.rwmix[DDIR_WRITE];
208
209 bytes_total += (bytes_total * perc) / 100;
210 } else
74939e38
JA
211 bytes_total <<= 1;
212 }
213
263e529f 214 if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) {
cf4464ca 215 double perc, perc_t;
263e529f 216
342f4be4 217 bytes_done = ddir_rw_sum(td->io_bytes);
476882d7
JA
218
219 if (bytes_total) {
220 perc = (double) bytes_done / (double) bytes_total;
221 if (perc > 1.0)
222 perc = 1.0;
223 } else
224 perc = 0.0;
263e529f 225
cf4464ca 226 if (td->o.time_based) {
476882d7
JA
227 if (timeout) {
228 perc_t = (double) elapsed / (double) timeout;
229 if (perc_t < perc)
230 perc = perc_t;
231 } else {
232 /*
233 * Will never hit, we can't have time_based
234 * without a timeout set.
235 */
236 perc = 0.0;
237 }
cf4464ca
JA
238 }
239
1e97cce9 240 eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
263e529f 241
d3eeeabc 242 if (td->o.timeout &&
0de5b26f
JA
243 eta_sec > (timeout + done_secs - elapsed))
244 eta_sec = timeout + done_secs - elapsed;
263e529f 245 } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED
b29ee5b3 246 || td->runstate == TD_INITIALIZED
714e85f3 247 || td->runstate == TD_SETTING_UP
b0f65863
JA
248 || td->runstate == TD_RAMP
249 || td->runstate == TD_PRE_READING) {
263e529f 250 int t_eta = 0, r_eta = 0;
342f4be4 251 unsigned long long rate_bytes;
263e529f
JA
252
253 /*
254 * We can only guess - assume it'll run the full timeout
255 * if given, otherwise assume it'll run at the specified rate.
256 */
b29ee5b3 257 if (td->o.timeout) {
0de5b26f
JA
258 uint64_t timeout = td->o.timeout;
259 uint64_t start_delay = td->o.start_delay;
260 uint64_t ramp_time = td->o.ramp_time;
261
262 t_eta = timeout + start_delay + ramp_time;
263 t_eta /= 1000000ULL;
b29ee5b3
JA
264
265 if (in_ramp_time(td)) {
266 unsigned long ramp_left;
267
cda99fa0 268 ramp_left = mtime_since_now(&td->epoch);
b29ee5b3
JA
269 ramp_left = (ramp_left + 999) / 1000;
270 if (ramp_left <= t_eta)
271 t_eta -= ramp_left;
272 }
273 }
342f4be4
JA
274 rate_bytes = ddir_rw_sum(td->o.rate);
275 if (rate_bytes) {
276 r_eta = (bytes_total / 1024) / rate_bytes;
0de5b26f 277 r_eta += (td->o.start_delay / 1000000ULL);
263e529f
JA
278 }
279
280 if (r_eta && t_eta)
281 eta_sec = min(r_eta, t_eta);
282 else if (r_eta)
283 eta_sec = r_eta;
284 else if (t_eta)
285 eta_sec = t_eta;
286 else
287 eta_sec = 0;
288 } else {
289 /*
290 * thread is already done or waiting for fsync
291 */
292 eta_sec = 0;
293 }
294
295 return eta_sec;
296}
297
771e58be
JA
298static void calc_rate(int unified_rw_rep, unsigned long mtime,
299 unsigned long long *io_bytes,
46fda8d0
JA
300 unsigned long long *prev_io_bytes, unsigned int *rate)
301{
b7f05eb0
JA
302 int i;
303
6eaf09d6 304 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
b7f05eb0
JA
305 unsigned long long diff;
306
307 diff = io_bytes[i] - prev_io_bytes[i];
771e58be
JA
308 if (unified_rw_rep) {
309 rate[i] = 0;
310 rate[0] += ((1000 * diff) / mtime) / 1024;
311 } else
312 rate[i] = ((1000 * diff) / mtime) / 1024;
6eaf09d6
SL
313
314 prev_io_bytes[i] = io_bytes[i];
b7f05eb0 315 }
46fda8d0 316}
5ec10eaa 317
771e58be
JA
318static void calc_iops(int unified_rw_rep, unsigned long mtime,
319 unsigned long long *io_iops,
adb02ba8
JA
320 unsigned long long *prev_io_iops, unsigned int *iops)
321{
6eaf09d6
SL
322 int i;
323
324 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
771e58be
JA
325 unsigned long long diff;
326
327 diff = io_iops[i] - prev_io_iops[i];
328 if (unified_rw_rep) {
329 iops[i] = 0;
330 iops[0] += (diff * 1000) / mtime;
331 } else
332 iops[i] = (diff * 1000) / mtime;
333
6eaf09d6
SL
334 prev_io_iops[i] = io_iops[i];
335 }
adb02ba8
JA
336}
337
263e529f
JA
338/*
339 * Print status of the jobs we know about. This includes rate estimates,
340 * ETA, thread state, etc.
341 */
af9c9fb3 342int calc_thread_status(struct jobs_eta *je, int force)
263e529f 343{
34572e28 344 struct thread_data *td;
771e58be 345 int i, unified_rw_rep;
b75a394f 346 unsigned long rate_time, disp_time, bw_avg_time, *eta_secs;
6eaf09d6
SL
347 unsigned long long io_bytes[DDIR_RWDIR_CNT];
348 unsigned long long io_iops[DDIR_RWDIR_CNT];
46fda8d0
JA
349 struct timeval now;
350
6eaf09d6
SL
351 static unsigned long long rate_io_bytes[DDIR_RWDIR_CNT];
352 static unsigned long long disp_io_bytes[DDIR_RWDIR_CNT];
353 static unsigned long long disp_io_iops[DDIR_RWDIR_CNT];
46fda8d0 354 static struct timeval rate_prev_time, disp_prev_time;
6043c579 355
af9c9fb3 356 if (!force) {
fc47559b
JA
357 if (output_format != FIO_OUTPUT_NORMAL &&
358 f_out == stdout)
f3afa57e
JA
359 return 0;
360 if (temp_stall_ts || eta_print == FIO_ETA_NEVER)
af9c9fb3 361 return 0;
e592a06b 362
af9c9fb3
JA
363 if (!isatty(STDOUT_FILENO) && (eta_print != FIO_ETA_ALWAYS))
364 return 0;
365 }
263e529f 366
342f4be4 367 if (!ddir_rw_sum(rate_io_bytes))
46fda8d0 368 fill_start_time(&rate_prev_time);
342f4be4 369 if (!ddir_rw_sum(disp_io_bytes))
46fda8d0 370 fill_start_time(&disp_prev_time);
6043c579 371
d3eeeabc
JA
372 eta_secs = malloc(thread_number * sizeof(unsigned long));
373 memset(eta_secs, 0, thread_number * sizeof(unsigned long));
263e529f 374
b75a394f
JA
375 je->elapsed_sec = (mtime_since_genesis() + 999) / 1000;
376
6eaf09d6
SL
377 io_bytes[DDIR_READ] = io_bytes[DDIR_WRITE] = io_bytes[DDIR_TRIM] = 0;
378 io_iops[DDIR_READ] = io_iops[DDIR_WRITE] = io_iops[DDIR_TRIM] = 0;
bb3884d8 379 bw_avg_time = ULONG_MAX;
771e58be 380 unified_rw_rep = 0;
34572e28 381 for_each_td(td, i) {
771e58be 382 unified_rw_rep += td->o.unified_rw_rep;
b7f05eb0
JA
383 if (is_power_of_2(td->o.kb_base))
384 je->is_pow2 = 1;
ad705bcb 385 je->unit_base = td->o.unit_base;
2dc1bbeb
JA
386 if (td->o.bw_avg_time < bw_avg_time)
387 bw_avg_time = td->o.bw_avg_time;
46fda8d0 388 if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING
b0f65863 389 || td->runstate == TD_FSYNCING
3d434057
JA
390 || td->runstate == TD_PRE_READING
391 || td->runstate == TD_FINISHING) {
b75a394f 392 je->nr_running++;
242c38db 393 if (td_read(td)) {
c2e9cc4d
JA
394 je->t_rate[0] += td->o.rate[DDIR_READ];
395 je->t_iops[0] += td->o.rate_iops[DDIR_READ];
396 je->m_rate[0] += td->o.ratemin[DDIR_READ];
397 je->m_iops[0] += td->o.rate_iops_min[DDIR_READ];
242c38db
JA
398 }
399 if (td_write(td)) {
c2e9cc4d
JA
400 je->t_rate[1] += td->o.rate[DDIR_WRITE];
401 je->t_iops[1] += td->o.rate_iops[DDIR_WRITE];
402 je->m_rate[1] += td->o.ratemin[DDIR_WRITE];
403 je->m_iops[1] += td->o.rate_iops_min[DDIR_WRITE];
242c38db 404 }
6eaf09d6 405 if (td_trim(td)) {
d79db122
JA
406 je->t_rate[2] += td->o.rate[DDIR_TRIM];
407 je->t_iops[2] += td->o.rate_iops[DDIR_TRIM];
408 je->m_rate[2] += td->o.ratemin[DDIR_TRIM];
409 je->m_iops[2] += td->o.rate_iops_min[DDIR_TRIM];
6eaf09d6
SL
410 }
411
b75a394f 412 je->files_open += td->nr_open_files;
b29ee5b3 413 } else if (td->runstate == TD_RAMP) {
b75a394f
JA
414 je->nr_running++;
415 je->nr_ramp++;
714e85f3 416 } else if (td->runstate == TD_SETTING_UP) {
9c6f6316 417 je->nr_running++;
714e85f3
JA
418 je->nr_setting_up++;
419 } else if (td->runstate < TD_RUNNING)
b75a394f 420 je->nr_pending++;
263e529f 421
b75a394f 422 if (je->elapsed_sec >= 3)
b29ee5b3 423 eta_secs[i] = thread_eta(td);
263e529f
JA
424 else
425 eta_secs[i] = INT_MAX;
426
427 check_str_update(td);
b29ee5b3 428
714e85f3 429 if (td->runstate > TD_SETTING_UP) {
6eaf09d6 430 int ddir;
771e58be 431
6eaf09d6 432 for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) {
771e58be
JA
433 if (unified_rw_rep) {
434 io_bytes[0] += td->io_bytes[ddir];
435 io_iops[0] += td->io_blocks[ddir];
436 } else {
437 io_bytes[ddir] += td->io_bytes[ddir];
438 io_iops[ddir] += td->io_blocks[ddir];
439 }
6eaf09d6 440 }
b29ee5b3 441 }
263e529f
JA
442 }
443
444 if (exitall_on_terminate)
b75a394f 445 je->eta_sec = INT_MAX;
263e529f 446 else
b75a394f 447 je->eta_sec = 0;
263e529f 448
34572e28 449 for_each_td(td, i) {
9c5a3854 450 if (exitall_on_terminate) {
b75a394f
JA
451 if (eta_secs[i] < je->eta_sec)
452 je->eta_sec = eta_secs[i];
9c5a3854 453 } else {
b75a394f
JA
454 if (eta_secs[i] > je->eta_sec)
455 je->eta_sec = eta_secs[i];
9c5a3854 456 }
263e529f
JA
457 }
458
eecf272f
JA
459 free(eta_secs);
460
46fda8d0
JA
461 fio_gettime(&now, NULL);
462 rate_time = mtime_since(&rate_prev_time, &now);
463
b29ee5b3 464 if (write_bw_log && rate_time > bw_avg_time && !in_ramp_time(td)) {
771e58be
JA
465 calc_rate(unified_rw_rep, rate_time, io_bytes, rate_io_bytes,
466 je->rate);
46fda8d0 467 memcpy(&rate_prev_time, &now, sizeof(now));
b75a394f
JA
468 add_agg_sample(je->rate[DDIR_READ], DDIR_READ, 0);
469 add_agg_sample(je->rate[DDIR_WRITE], DDIR_WRITE, 0);
6eaf09d6 470 add_agg_sample(je->rate[DDIR_TRIM], DDIR_TRIM, 0);
6043c579
JA
471 }
472
46fda8d0 473 disp_time = mtime_since(&disp_prev_time, &now);
a5b01f1b
JA
474
475 /*
476 * Allow a little slack, the target is to print it every 1000 msecs
477 */
af9c9fb3 478 if (!force && disp_time < 900)
b75a394f 479 return 0;
46fda8d0 480
771e58be
JA
481 calc_rate(unified_rw_rep, disp_time, io_bytes, disp_io_bytes, je->rate);
482 calc_iops(unified_rw_rep, disp_time, io_iops, disp_io_iops, je->iops);
adb02ba8 483
46fda8d0
JA
484 memcpy(&disp_prev_time, &now, sizeof(now));
485
af9c9fb3 486 if (!force && !je->nr_running && !je->nr_pending)
b75a394f
JA
487 return 0;
488
1d1f45ae
JA
489 je->nr_threads = thread_number;
490 memcpy(je->run_str, run_str, thread_number * sizeof(char));
b75a394f
JA
491 return 1;
492}
493
cf451d1e 494void display_thread_status(struct jobs_eta *je)
b75a394f 495{
e382e661
JA
496 static struct timeval disp_eta_new_line;
497 static int eta_new_line_init, eta_new_line_pending;
b75a394f
JA
498 static int linelen_last;
499 static int eta_good;
79074e7c 500 char output[REAL_MAX_JOBS + 512], *p = output;
b75a394f
JA
501 char eta_str[128];
502 double perc = 0.0;
b75a394f 503
cf451d1e
JA
504 if (je->eta_sec != INT_MAX && je->elapsed_sec) {
505 perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec);
506 eta_to_str(eta_str, je->eta_sec);
b75a394f
JA
507 }
508
e382e661
JA
509 if (eta_new_line_pending) {
510 eta_new_line_pending = 0;
511 p += sprintf(p, "\n");
512 }
513
cf451d1e 514 p += sprintf(p, "Jobs: %d (f=%d)", je->nr_running, je->files_open);
3e47bd25 515 if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
581e7141
JA
516 char *tr, *mr;
517
22f80458
JA
518 mr = num2str(je->m_rate[0] + je->m_rate[1], 4, 0, je->is_pow2, 8);
519 tr = num2str(je->t_rate[0] + je->t_rate[1], 4, 0, je->is_pow2, 8);
37db14fe 520 p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
581e7141
JA
521 free(tr);
522 free(mr);
3e47bd25
JA
523 } else if (je->m_iops[0] || je->m_iops[1] || je->t_iops[0] || je->t_iops[1]) {
524 p += sprintf(p, ", CR=%d/%d IOPS",
525 je->t_iops[0] + je->t_iops[1],
88e4beaa 526 je->m_iops[0] + je->m_iops[1]);
3e47bd25 527 }
cf451d1e 528 if (je->eta_sec != INT_MAX && je->nr_running) {
0721d11e 529 char perc_str[32];
6eaf09d6
SL
530 char *iops_str[DDIR_RWDIR_CNT];
531 char *rate_str[DDIR_RWDIR_CNT];
79074e7c 532 size_t left;
adb02ba8 533 int l;
6eaf09d6 534 int ddir;
5ec10eaa 535
cf451d1e 536 if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running)
cac58fd5
JA
537 strcpy(perc_str, "-.-% done");
538 else {
714e85f3
JA
539 double mult = 100.0;
540
541 if (je->nr_setting_up && je->nr_running)
542 mult *= (1.0 - (double) je->nr_setting_up / (double) je->nr_running);
543
cac58fd5 544 eta_good = 1;
714e85f3 545 perc *= mult;
0721d11e 546 sprintf(perc_str, "%3.1f%% done", perc);
cac58fd5 547 }
0721d11e 548
6eaf09d6
SL
549 for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) {
550 rate_str[ddir] = num2str(je->rate[ddir], 5,
ad705bcb 551 1024, je->is_pow2, je->unit_base);
73798eb2 552 iops_str[ddir] = num2str(je->iops[ddir], 4, 1, 0, 0);
6eaf09d6 553 }
adb02ba8 554
79074e7c
JA
555 left = sizeof(output) - (p - output) - 1;
556
6eaf09d6
SL
557 l = snprintf(p, left, ": [%s] [%s] [%s/%s/%s /s] [%s/%s/%s iops] [eta %s]",
558 je->run_str, perc_str, rate_str[DDIR_READ],
559 rate_str[DDIR_WRITE], rate_str[DDIR_TRIM],
560 iops_str[DDIR_READ], iops_str[DDIR_WRITE],
561 iops_str[DDIR_TRIM], eta_str);
37db14fe 562 p += l;
adb02ba8 563 if (l >= 0 && l < linelen_last)
37db14fe 564 p += sprintf(p, "%*s", linelen_last - l, "");
adb02ba8 565 linelen_last = l;
d1bd7213 566
6eaf09d6
SL
567 for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) {
568 free(rate_str[ddir]);
569 free(iops_str[ddir]);
570 }
263e529f 571 }
37db14fe
JA
572 p += sprintf(p, "\r");
573
3e47bd25 574 printf("%s", output);
e382e661
JA
575
576 if (!eta_new_line_init) {
577 fio_gettime(&disp_eta_new_line, NULL);
578 eta_new_line_init = 1;
579 } else if (eta_new_line &&
580 mtime_since_now(&disp_eta_new_line) > eta_new_line * 1000) {
581 fio_gettime(&disp_eta_new_line, NULL);
582 eta_new_line_pending = 1;
583 }
584
3e47bd25 585 fflush(stdout);
263e529f
JA
586}
587
cf451d1e
JA
588void print_thread_status(void)
589{
1d1f45ae 590 struct jobs_eta *je;
b814fb26 591 size_t size;
1d1f45ae 592
b814fb26
JA
593 if (!thread_number)
594 return;
cf451d1e 595
b814fb26
JA
596 size = sizeof(*je) + thread_number * sizeof(char) + 1;
597 je = malloc(size);
598 memset(je, 0, size);
cf451d1e 599
af9c9fb3 600 if (calc_thread_status(je, 0))
1d1f45ae 601 display_thread_status(je);
cf451d1e 602
1d1f45ae 603 free(je);
cf451d1e 604}
b75a394f 605
2b13e716 606void print_status_init(int thr_number)
263e529f 607{
3e2e48a7
JA
608 __run_str[thr_number] = 'P';
609 update_condensed_str(__run_str, run_str);
263e529f 610}