- printf("Jobs: %d (f=%d)", nr_running, files_open);
- if (m_rate || t_rate)
- printf(", CR=%d/%d KiB/s", t_rate, m_rate);
- else if (m_iops || t_iops)
- printf(", CR=%d/%d IOPS", t_iops, m_iops);
- if (eta_sec != INT_MAX && nr_running) {
- perc *= 100.0;
- printf(": [%s] [%3.1f%% done] [%6u/%6u kb/s] [eta %s]", run_str, perc, rate[0], rate[1], eta_str);
+void display_thread_status(struct jobs_eta *je)
+{
+ static int linelen_last;
+ static int eta_good;
+ char output[REAL_MAX_JOBS + 512], *p = output;
+ char eta_str[128];
+ double perc = 0.0;
+
+ if (je->eta_sec != INT_MAX && je->elapsed_sec) {
+ perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec);
+ eta_to_str(eta_str, je->eta_sec);
+ }
+
+ p += sprintf(p, "Jobs: %d (f=%d)", je->nr_running, je->files_open);
+ if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
+ char *tr, *mr;
+
+ mr = num2str(je->m_rate[0] + je->m_rate[1], 4, 0, je->is_pow2);
+ tr = num2str(je->t_rate[0] + je->t_rate[1], 4, 0, je->is_pow2);
+ p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
+ free(tr);
+ free(mr);
+ } else if (je->m_iops[0] || je->m_iops[1] || je->t_iops[0] || je->t_iops[1]) {
+ p += sprintf(p, ", CR=%d/%d IOPS",
+ je->t_iops[0] + je->t_iops[1],
+ je->m_iops[0] + je->m_iops[1]);
+ }
+ if (je->eta_sec != INT_MAX && je->nr_running) {
+ char perc_str[32];
+ char *iops_str[DDIR_RWDIR_CNT];
+ char *rate_str[DDIR_RWDIR_CNT];
+ size_t left;
+ int l;
+ int ddir;
+
+ if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running)
+ strcpy(perc_str, "-.-% done");
+ else {
+ eta_good = 1;
+ perc *= 100.0;
+ sprintf(perc_str, "%3.1f%% done", perc);
+ }
+
+ for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) {
+ rate_str[ddir] = num2str(je->rate[ddir], 5,
+ 1024, je->is_pow2);
+ iops_str[ddir] = num2str(je->iops[ddir], 4, 1, 0);
+ }
+
+ left = sizeof(output) - (p - output) - 1;
+
+ l = snprintf(p, left, ": [%s] [%s] [%s/%s/%s /s] [%s/%s/%s iops] [eta %s]",
+ je->run_str, perc_str, rate_str[DDIR_READ],
+ rate_str[DDIR_WRITE], rate_str[DDIR_TRIM],
+ iops_str[DDIR_READ], iops_str[DDIR_WRITE],
+ iops_str[DDIR_TRIM], eta_str);
+ p += l;
+ if (l >= 0 && l < linelen_last)
+ p += sprintf(p, "%*s", linelen_last - l, "");
+ linelen_last = l;
+
+ for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) {
+ free(rate_str[ddir]);
+ free(iops_str[ddir]);
+ }