+ const fio_fp64_t fa = *(const fio_fp64_t *) a;
+ const fio_fp64_t fb = *(const fio_fp64_t *) b;
+ int cmp = 0;
+
+ if (fa.u.f > fb.u.f)
+ cmp = 1;
+ else if (fa.u.f < fb.u.f)
+ cmp = -1;
+
+ return cmp;
+}
+
+/*
+ * 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)
+{
+ unsigned long sum = 0;
+ unsigned int len, i, j = 0;
+ int is_last = 0;
+
+ len = 0;
+ while (len < FIO_IO_U_LIST_MAX_LEN && plist[len].u.f != 0.0)
+ len++;
+
+ /*
+ * Sort the percentile list. Note that it may already be sorted if
+ * we are using the default values, but since it's a short list this
+ * isn't a worry. Also note that this does not work for NaN values.
+ */
+ if (len > 1)
+ qsort((void*)plist, len, sizeof(plist[0]), double_cmp);
+
+ log_info(" clat percentiles (usec) :");
+
+ for (i = 0; i < FIO_IO_U_PLAT_NR && !is_last; i++) {
+ sum += io_u_plat[i];
+ while (sum >= (plist[j].u.f / 100.0 * nr)) {
+ assert(plist[j].u.f <= 100.0);
+
+ /* for formatting */
+ if (j != 0 && (j % 4) == 0)
+ log_info(" ");