+ if (ts->ss_dur) {
+ struct json_object *data;
+ struct json_array *iops, *bw;
+ int i, j, k;
+ char ss_buf[64];
+
+ snprintf(ss_buf, sizeof(ss_buf), "%s%s:%f%s",
+ ts->ss_state & __FIO_SS_IOPS ? "iops" : "bw",
+ ts->ss_state & __FIO_SS_SLOPE ? "_slope" : "",
+ (float) ts->ss_limit.u.f,
+ ts->ss_state & __FIO_SS_PCT ? "%" : "");
+
+ tmp = json_create_object();
+ json_object_add_value_object(root, "steadystate", tmp);
+ json_object_add_value_string(tmp, "ss", ss_buf);
+ json_object_add_value_int(tmp, "duration", (int)ts->ss_dur);
+ json_object_add_value_int(tmp, "attained", (ts->ss_state & __FIO_SS_ATTAINED) > 0);
+
+ snprintf(ss_buf, sizeof(ss_buf), "%f%s", (float) ts->ss_criterion.u.f,
+ ts->ss_state & __FIO_SS_PCT ? "%" : "");
+ json_object_add_value_string(tmp, "criterion", ss_buf);
+ json_object_add_value_float(tmp, "max_deviation", ts->ss_deviation.u.f);
+ json_object_add_value_float(tmp, "slope", ts->ss_slope.u.f);
+
+ data = json_create_object();
+ json_object_add_value_object(tmp, "data", data);
+ bw = json_create_array();
+ iops = json_create_array();
+
+ /*
+ ** if ss was attained or the buffer is not full,
+ ** ss->head points to the first element in the list.
+ ** otherwise it actually points to the second element
+ ** in the list
+ */
+ if ((ts->ss_state & __FIO_SS_ATTAINED) || !(ts->ss_state & __FIO_SS_BUFFER_FULL))
+ j = ts->ss_head;
+ else
+ j = ts->ss_head == 0 ? ts->ss_dur - 1 : ts->ss_head - 1;
+ for (i = 0; i < ts->ss_dur; i++) {
+ k = (j + i) % ts->ss_dur;
+ json_array_add_value_int(bw, ts->ss_bw_data[k]);
+ json_array_add_value_int(iops, ts->ss_iops_data[k]);
+ }
+ json_object_add_value_int(data, "bw_mean", steadystate_bw_mean(ts));
+ json_object_add_value_int(data, "iops_mean", steadystate_iops_mean(ts));
+ json_object_add_value_array(data, "iops", iops);
+ json_object_add_value_array(data, "bw", bw);
+ }
+