long ul1, ul2;
double uf;
char **cp = NULL;
+ char *cp2;
int ret = 0, is_time = 0;
const struct value_pair *vp;
struct value_pair posval[PARSE_MAX_VP];
- int i, all_skipped = 1;
+ int i, len, all_skipped = 1;
dprint(FD_PARSE, "__handle_option=%s, type=%d, ptr=%s\n", o->name,
o->type, ptr);
break;
}
case FIO_OPT_FLOAT_LIST: {
+ if (first) {
+ /*
+ ** Initialize precision to 0 and zero out list
+ ** in case specified list is shorter than default
+ */
+ ul2 = 0;
+ ilp = td_var(data, o->off2);
+ *ilp = ul2;
+
+ flp = td_var(data, o->off1);
+ for(i = 0; i < o->maxlen; i++)
+ flp[i].u.f = 0.0;
+ }
if (curr >= o->maxlen) {
log_err("the list exceeding max length %d\n",
o->maxlen);
flp = td_var(data, o->off1);
flp[curr].u.f = uf;
+ /*
+ ** Calculate precision for output by counting
+ ** number of digits after period. Find first
+ ** period in entire remaining list each time
+ */
+ cp2 = strchr(ptr, '.');
+ if (cp2 != NULL) {
+ len = 0;
+
+ while (*++cp2 != '\0' && *cp2 >= '0' && *cp2 <= '9')
+ len++;
+
+ ilp = td_var(data, o->off2);
+ if (len > *ilp)
+ *ilp = len;
+ }
+
break;
}
case FIO_OPT_STR_STORE: {
* 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, uint64_t precision)
{
unsigned int len, j = 0, minv, maxv;
unsigned int *ovals;
int is_last, scale_down;
+ char buf1[32], buf2[32];
len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv);
if (!len)
log_info(" clat percentiles (usec):\n |");
}
+ snprintf(buf1, sizeof(buf1), " %%1.%luf", precision);
+ snprintf(buf2, sizeof(buf1), "%%1.%luf", precision);
for (j = 0; j < len; j++) {
- char fbuf[8];
+ char fbuf[16];
/* for formatting */
if (j != 0 && (j % 4) == 0)
is_last = (j == len - 1);
if (plist[j].u.f < 10.0)
- sprintf(fbuf, " %2.2f", plist[j].u.f);
+ snprintf(fbuf, sizeof(fbuf), buf1, plist[j].u.f);
else
- sprintf(fbuf, "%2.2f", plist[j].u.f);
+ snprintf(fbuf, sizeof(fbuf), buf2, plist[j].u.f);
if (scale_down)
ovals[j] = (ovals[j] + 999) / 1000;
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), "%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]);
}
ts = &threadstats[j];
ts->clat_percentiles = td->o.clat_percentiles;
+ ts->percentile_precision = td->o.percentile_precision;
memcpy(ts->percentile_list, td->o.percentile_list, sizeof(td->o.percentile_list));
idx++;