struct fio_mutex *stat_mutex;
+void clear_rusage_stat(struct thread_data *td)
+{
+ struct thread_stat *ts = &td->ts;
+
+ fio_getrusage(&td->ru_start);
+ ts->usr_time = ts->sys_time = 0;
+ ts->ctx = 0;
+ ts->minf = ts->majf = 0;
+}
+
void update_rusage_stat(struct thread_data *td)
{
struct thread_stat *ts = &td->ts;
unsigned int len, minv, maxv;
int i;
const char *ddirname[] = {"read", "write", "trim"};
- struct json_object *dir_object, *tmp_object, *percentile_object;
+ struct json_object *dir_object, *tmp_object, *percentile_object, *clat_bins_object;
char buf[120];
double p_of_agg = 100.0;
json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]);
}
+ if (output_format & FIO_OUTPUT_JSON_PLUS) {
+ clat_bins_object = json_create_object();
+ json_object_add_value_object(tmp_object, "bins", clat_bins_object);
+ for(i = 0; i < FIO_IO_U_PLAT_NR; i++) {
+ snprintf(buf, sizeof(buf), "%d", i);
+ json_object_add_value_int(clat_bins_object, (const char *)buf, ts->io_u_plat[ddir][i]);
+ }
+ json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_BITS", FIO_IO_U_PLAT_BITS);
+ json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_VAL", FIO_IO_U_PLAT_VAL);
+ json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_NR", FIO_IO_U_PLAT_NR);
+ }
+
if (!calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) {
min = max = 0;
mean = dev = 0.0;
json_object_add_value_int(root, "error", ts->error);
/* ETA Info */
- je = get_jobs_eta(1, &size);
+ je = get_jobs_eta(true, &size);
if (je) {
json_object_add_value_int(root, "eta", je->eta_sec);
json_object_add_value_int(root, "elapsed", je->elapsed_sec);
return ret;
}
-static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr)
+static void sum_stat(struct io_stat *dst, struct io_stat *src, bool first)
{
double mean, S;
* <http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
* #Parallel_algorithm>
*/
- if (nr == 1) {
+ if (first) {
mean = src->mean.u.f;
S = src->S.u.f;
} else {
dst->unit_base = src->unit_base;
}
-void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr)
+void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src,
+ bool first)
{
int l, k;
for (l = 0; l < DDIR_RWDIR_CNT; l++) {
if (!dst->unified_rw_rep) {
- sum_stat(&dst->clat_stat[l], &src->clat_stat[l], nr);
- sum_stat(&dst->slat_stat[l], &src->slat_stat[l], nr);
- sum_stat(&dst->lat_stat[l], &src->lat_stat[l], nr);
- sum_stat(&dst->bw_stat[l], &src->bw_stat[l], nr);
+ sum_stat(&dst->clat_stat[l], &src->clat_stat[l], first);
+ sum_stat(&dst->slat_stat[l], &src->slat_stat[l], first);
+ sum_stat(&dst->lat_stat[l], &src->lat_stat[l], first);
+ sum_stat(&dst->bw_stat[l], &src->bw_stat[l], first);
dst->io_bytes[l] += src->io_bytes[l];
if (dst->runtime[l] < src->runtime[l])
dst->runtime[l] = src->runtime[l];
} else {
- sum_stat(&dst->clat_stat[0], &src->clat_stat[l], nr);
- sum_stat(&dst->slat_stat[0], &src->slat_stat[l], nr);
- sum_stat(&dst->lat_stat[0], &src->lat_stat[l], nr);
- sum_stat(&dst->bw_stat[0], &src->bw_stat[l], nr);
+ sum_stat(&dst->clat_stat[0], &src->clat_stat[l], first);
+ sum_stat(&dst->slat_stat[0], &src->slat_stat[l], first);
+ sum_stat(&dst->lat_stat[0], &src->lat_stat[l], first);
+ sum_stat(&dst->bw_stat[0], &src->bw_stat[l], first);
dst->io_bytes[0] += src->io_bytes[l];
if (dst->runtime[0] < src->runtime[l])
dst->runtime[0] = src->runtime[l];
+
+ /*
+ * We're summing to the same destination, so override
+ * 'first' after the first iteration of the loop
+ */
+ first = false;
}
}
for (k = 0; k < ts->nr_block_infos; k++)
ts->block_infos[k] = td->ts.block_infos[k];
- sum_thread_stats(ts, &td->ts, idx);
+ sum_thread_stats(ts, &td->ts, idx == 1);
}
for (i = 0; i < nr_ts; i++) {
show_thread_status_normal(ts, rs, &output[__FIO_OUTPUT_NORMAL]);
}
}
- if (output_format & FIO_OUTPUT_JSON) {
+ if (!is_backend && (output_format & FIO_OUTPUT_JSON)) {
/* disk util stats, if any */
show_disk_util(1, root, &output[__FIO_OUTPUT_JSON]);