* Find and display the p-th percentile of clat
*/
static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
- fio_fp64_t *plist)
+ fio_fp64_t *plist, unsigned int precision)
{
unsigned int len, j = 0, minv, maxv;
unsigned int *ovals;
- int is_last, scale_down;
+ int is_last, per_line, scale_down;
+ char fmt[32];
len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv);
if (!len)
log_info(" clat percentiles (usec):\n |");
}
+ snprintf(fmt, sizeof(fmt), "%%1.%uf", precision);
+ per_line = (80 - 7) / (precision + 14);
+
for (j = 0; j < len; j++) {
- char fbuf[8];
+ char fbuf[16], *ptr = fbuf;
/* for formatting */
- if (j != 0 && (j % 4) == 0)
+ if (j != 0 && (j % per_line) == 0)
log_info(" |");
/* end of the list */
is_last = (j == len - 1);
if (plist[j].u.f < 10.0)
- sprintf(fbuf, " %2.2f", plist[j].u.f);
- else
- sprintf(fbuf, "%2.2f", plist[j].u.f);
+ ptr += sprintf(fbuf, " ");
+
+ snprintf(ptr, sizeof(fbuf), fmt, plist[j].u.f);
if (scale_down)
ovals[j] = (ovals[j] + 999) / 1000;
if (is_last)
break;
- if (j % 4 == 3) /* for formatting */
+ if ((j % per_line) == per_line - 1) /* for formatting */
log_info("\n");
}
if (ts->clat_percentiles) {
show_clat_percentiles(ts->io_u_plat[ddir],
ts->clat_stat[ddir].samples,
- ts->percentile_list);
+ ts->percentile_list,
+ ts->percentile_precision);
}
if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
double p_of_agg = 100.0;
log_info(";0%%=0");
continue;
}
- log_info(";%2.2f%%=%u", ts->percentile_list[i].u.f, ovals[i]);
+ log_info(";%f%%=%u", ts->percentile_list[i].u.f, ovals[i]);
}
if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev))
json_object_add_value_int(percentile_object, "0.00", 0);
continue;
}
- snprintf(buf, sizeof(buf) - 1, "%2.2f", ts->percentile_list[i].u.f);
+ snprintf(buf, sizeof(buf), "%f", ts->percentile_list[i].u.f);
json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]);
}
for (i = 0; i < 7; i++) {
char name[20];
if (i < 6)
- snprintf(name, 19, "%d", 1 << i);
+ snprintf(name, 20, "%d", 1 << i);
else
- snprintf(name, 19, ">=%d", 1 << i);
+ snprintf(name, 20, ">=%d", 1 << i);
json_object_add_value_float(tmp, (const char *)name, io_u_dist[i]);
}
ts = &threadstats[j];
ts->clat_percentiles = td->o.clat_percentiles;
- if (td->o.overwrite_plist)
- memcpy(ts->percentile_list, td->o.percentile_list, sizeof(td->o.percentile_list));
- else
- memcpy(ts->percentile_list, def_percentile_list, sizeof(def_percentile_list));
+ ts->percentile_precision = td->o.percentile_precision;
+ memcpy(ts->percentile_list, td->o.percentile_list, sizeof(td->o.percentile_list));
idx++;
ts->members++;