+ je->nr_threads = thread_number;
+ memcpy(je->run_str, run_str, thread_number * sizeof(char));
+
+ return 1;
+}
+
+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 || je->t_rate) {
+ char *tr, *mr;
+
+ mr = num2str(je->m_rate, 4, 0, je->is_pow2);
+ tr = num2str(je->t_rate, 4, 0, je->is_pow2);
+ p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
+ free(tr);
+ free(mr);
+ } else if (je->m_iops || je->t_iops)
+ p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops);
+ 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]);
+ }