@@ -117,6 +117,7 @@ run_stats::run_stats(benchmark_config *config) :
117
117
{
118
118
memset (&m_start_time, 0 , sizeof (m_start_time));
119
119
memset (&m_end_time, 0 , sizeof (m_end_time));
120
+ quantiles_list = config->print_percentiles .quantile_list ;
120
121
121
122
if (config->arbitrary_commands ->is_defined ()) {
122
123
setup_arbitrary_commands (config->arbitrary_commands ->size ());
@@ -155,6 +156,16 @@ void run_stats::roll_cur_stats(struct timeval* ts)
155
156
{
156
157
const unsigned int sec = ts_diff (m_start_time, *ts) / 1000000 ;
157
158
if (sec > m_cur_stats.m_second ) {
159
+ m_cur_stats.m_get_cmd .summarize_quantiles (inst_m_get_latency_histogram,quantiles_list);
160
+ m_cur_stats.m_set_cmd .summarize_quantiles (inst_m_set_latency_histogram,quantiles_list);
161
+ m_cur_stats.m_wait_cmd .summarize_quantiles (inst_m_wait_latency_histogram,quantiles_list);
162
+ for (unsigned int i=0 ; i<m_cur_stats.m_ar_commands .size (); i++) {
163
+ m_cur_stats.m_ar_commands [i].summarize_quantiles (inst_m_ar_commands_latency_histograms[i],quantiles_list);
164
+ hdr_reset (inst_m_ar_commands_latency_histograms[i]);
165
+ }
166
+ hdr_reset (inst_m_get_latency_histogram);
167
+ hdr_reset (inst_m_set_latency_histogram);
168
+ hdr_reset (inst_m_wait_latency_histogram);
158
169
m_stats.push_back (m_cur_stats);
159
170
m_cur_stats.reset (sec);
160
171
}
@@ -166,7 +177,7 @@ void run_stats::update_get_op(struct timeval* ts, unsigned int bytes, unsigned i
166
177
m_cur_stats.m_get_cmd .update_op (bytes, latency, hits, misses);
167
178
m_totals.update_op (bytes, latency);
168
179
hdr_record_value (m_get_latency_histogram,latency);
169
-
180
+ hdr_record_value (inst_m_get_latency_histogram,latency);
170
181
}
171
182
172
183
void run_stats::update_set_op (struct timeval * ts, unsigned int bytes, unsigned int latency)
@@ -176,6 +187,7 @@ void run_stats::update_set_op(struct timeval* ts, unsigned int bytes, unsigned i
176
187
m_cur_stats.m_set_cmd .update_op (bytes, latency);
177
188
m_totals.update_op (bytes, latency);
178
189
hdr_record_value (m_set_latency_histogram,latency);
190
+ hdr_record_value (inst_m_set_latency_histogram,latency);
179
191
}
180
192
181
193
void run_stats::update_moved_get_op (struct timeval * ts, unsigned int bytes, unsigned int latency)
@@ -185,6 +197,7 @@ void run_stats::update_moved_get_op(struct timeval* ts, unsigned int bytes, unsi
185
197
m_cur_stats.m_get_cmd .update_moved_op (bytes, latency);
186
198
m_totals.update_op (bytes, latency);
187
199
hdr_record_value (m_get_latency_histogram,latency);
200
+ hdr_record_value (inst_m_get_latency_histogram,latency);
188
201
}
189
202
190
203
void run_stats::update_moved_set_op (struct timeval * ts, unsigned int bytes, unsigned int latency)
@@ -194,6 +207,7 @@ void run_stats::update_moved_set_op(struct timeval* ts, unsigned int bytes, unsi
194
207
m_cur_stats.m_set_cmd .update_moved_op (bytes, latency);
195
208
m_totals.update_op (bytes, latency);
196
209
hdr_record_value (m_set_latency_histogram,latency);
210
+ hdr_record_value (inst_m_set_latency_histogram,latency);
197
211
}
198
212
199
213
void run_stats::update_ask_get_op (struct timeval * ts, unsigned int bytes, unsigned int latency)
@@ -203,6 +217,7 @@ void run_stats::update_ask_get_op(struct timeval* ts, unsigned int bytes, unsign
203
217
m_cur_stats.m_get_cmd .update_ask_op (bytes, latency);
204
218
m_totals.update_op (bytes, latency);
205
219
hdr_record_value (m_get_latency_histogram,latency);
220
+ hdr_record_value (inst_m_get_latency_histogram,latency);
206
221
}
207
222
208
223
void run_stats::update_ask_set_op (struct timeval * ts, unsigned int bytes, unsigned int latency)
@@ -212,6 +227,7 @@ void run_stats::update_ask_set_op(struct timeval* ts, unsigned int bytes, unsign
212
227
m_cur_stats.m_set_cmd .update_ask_op (bytes, latency);
213
228
m_totals.update_op (bytes, latency);
214
229
hdr_record_value (m_set_latency_histogram,latency);
230
+ hdr_record_value (inst_m_set_latency_histogram,latency);
215
231
}
216
232
217
233
void run_stats::update_wait_op (struct timeval *ts, unsigned int latency)
@@ -221,6 +237,7 @@ void run_stats::update_wait_op(struct timeval *ts, unsigned int latency)
221
237
m_cur_stats.m_wait_cmd .update_op (0 , latency);
222
238
m_totals.update_op (0 , latency);
223
239
hdr_record_value (m_wait_latency_histogram,latency);
240
+ hdr_record_value (inst_m_wait_latency_histogram,latency);
224
241
}
225
242
226
243
void run_stats::update_arbitrary_op (struct timeval *ts, unsigned int bytes,
@@ -231,7 +248,9 @@ void run_stats::update_arbitrary_op(struct timeval *ts, unsigned int bytes,
231
248
m_totals.update_op (bytes, latency);
232
249
233
250
struct hdr_histogram * hist = m_ar_commands_latency_histograms.at (request_index);
251
+ struct hdr_histogram * inst_hist = inst_m_ar_commands_latency_histograms.at (request_index);
234
252
hdr_record_value (hist,latency);
253
+ hdr_record_value (inst_hist,latency);
235
254
}
236
255
237
256
unsigned int run_stats::get_duration (void )
@@ -828,22 +847,23 @@ void result_print_to_json(json_handler * jsonhandler, const char * type, double
828
847
char timestamp_str[16 ];
829
848
one_sec_cmd_stats cmd_stats = timeserie_stats[i];
830
849
const unsigned int timestamp = timestamps[i];
831
- const bool sec_has_samples = hdr_total_count (cmd_stats.latency_histogram )>0 ;
832
- const double sec_avg_latency = sec_has_samples ? hdr_mean (cmd_stats.latency_histogram )/ (double ) LATENCY_HDR_RESULTS_MULTIPLIER : 0.0 ;
833
- const double sec_min_latency = has_samples ? hdr_min (cmd_stats.latency_histogram )/ (double ) LATENCY_HDR_RESULTS_MULTIPLIER : 0.0 ;
834
- const double sec_max_latency = has_samples ? hdr_max (cmd_stats.latency_histogram )/ (double ) LATENCY_HDR_RESULTS_MULTIPLIER : 0.0 ;
850
+ const bool sec_has_samples = cmd_stats.m_ops > 0 ;
835
851
snprintf (timestamp_str,sizeof (timestamp_str)-1 ," %d" , timestamp);
836
852
jsonhandler->open_nesting (timestamp_str);
837
- jsonhandler->write_obj (" Count" ," %lld" , hdr_total_count (cmd_stats.latency_histogram ));
838
- jsonhandler->write_obj (" Average Latency" ," %.2f" , sec_avg_latency);
839
- jsonhandler->write_obj (" Min Latency" ," %.2f" , sec_min_latency);
840
- jsonhandler->write_obj (" Max Latency" ," %.2f" , sec_max_latency);
841
- for (std::size_t i = 0 ; i < quantile_list.size (); i++){
842
- const float quantile = quantile_list[i];
843
- char quantile_header[8 ];
844
- snprintf (quantile_header,sizeof (quantile_header)-1 ," p%.2f" , quantile);
845
- const double value = hdr_value_at_percentile (cmd_stats.latency_histogram , quantile )/ (double ) LATENCY_HDR_RESULTS_MULTIPLIER;
846
- jsonhandler->write_obj ((char *)quantile_header," %.2f" , value);
853
+ jsonhandler->write_obj (" Count" ," %lld" , cmd_stats.m_ops );
854
+ if (sec_has_samples){
855
+ jsonhandler->write_obj (" Average Latency" ," %.3f" , cmd_stats.m_avg_latency );
856
+ jsonhandler->write_obj (" Min Latency" ," %.3f" , cmd_stats.m_min_latency );
857
+ jsonhandler->write_obj (" Max Latency" ," %.3f" , cmd_stats.m_max_latency );
858
+ for (std::size_t i = 0 ; i < quantile_list.size (); i++){
859
+ if (i < cmd_stats.summarized_quantile_values .size ()){
860
+ const float quantile = quantile_list[i];
861
+ char quantile_header[8 ];
862
+ snprintf (quantile_header,sizeof (quantile_header)-1 ," p%.2f" , quantile);
863
+ const double value = cmd_stats.summarized_quantile_values [i];
864
+ jsonhandler->write_obj ((char *)quantile_header," %.3f" , value);
865
+ }
866
+ }
847
867
}
848
868
jsonhandler->close_nesting ();
849
869
}
@@ -1103,7 +1123,7 @@ void run_stats::print_kb_sec_column(output_table &table) {
1103
1123
table.add_column (column);
1104
1124
}
1105
1125
1106
- void run_stats::print_json (json_handler *jsonhandler, arbitrary_command_list& command_list, bool cluster_mode, std::vector< float > quantile_list ) {
1126
+ void run_stats::print_json (json_handler *jsonhandler, arbitrary_command_list& command_list, bool cluster_mode) {
1107
1127
if (jsonhandler != NULL ){ // Added for double verification in case someone accidently send NULL.
1108
1128
jsonhandler->open_nesting (" Runtime" );
1109
1129
const unsigned long long start_time_ms = (m_start_time.tv_sec * 1000000 + m_start_time.tv_usec )/1000 ;
@@ -1133,7 +1153,7 @@ void run_stats::print_json(json_handler *jsonhandler, arbitrary_command_list& co
1133
1153
cluster_mode ? m_totals.m_ar_commands [i].m_moved_sec : -1 ,
1134
1154
cluster_mode ? m_totals.m_ar_commands [i].m_ask_sec : -1 ,
1135
1155
m_totals.m_ar_commands [i].m_bytes_sec ,
1136
- quantile_list ,
1156
+ quantiles_list ,
1137
1157
arbitrary_command_latency_histogram,
1138
1158
timestamps,
1139
1159
arbitrary_command_stats
@@ -1149,7 +1169,7 @@ void run_stats::print_json(json_handler *jsonhandler, arbitrary_command_list& co
1149
1169
cluster_mode ? m_totals.m_set_cmd .m_moved_sec : -1 ,
1150
1170
cluster_mode ? m_totals.m_set_cmd .m_ask_sec : -1 ,
1151
1171
m_totals.m_set_cmd .m_bytes_sec ,
1152
- quantile_list ,
1172
+ quantiles_list ,
1153
1173
m_set_latency_histogram,
1154
1174
timestamps,
1155
1175
set_stats
@@ -1160,7 +1180,7 @@ void run_stats::print_json(json_handler *jsonhandler, arbitrary_command_list& co
1160
1180
cluster_mode ? m_totals.m_get_cmd .m_moved_sec : -1 ,
1161
1181
cluster_mode ? m_totals.m_get_cmd .m_ask_sec : -1 ,
1162
1182
m_totals.m_get_cmd .m_bytes_sec ,
1163
- quantile_list ,
1183
+ quantiles_list ,
1164
1184
m_get_latency_histogram,
1165
1185
timestamps,
1166
1186
get_stats
@@ -1171,7 +1191,7 @@ void run_stats::print_json(json_handler *jsonhandler, arbitrary_command_list& co
1171
1191
cluster_mode ? 0.0 : -1 ,
1172
1192
cluster_mode ? 0.0 : -1 ,
1173
1193
0.0 ,
1174
- quantile_list ,
1194
+ quantiles_list ,
1175
1195
m_wait_latency_histogram,
1176
1196
timestamps,
1177
1197
wait_stats
@@ -1184,7 +1204,7 @@ void run_stats::print_json(json_handler *jsonhandler, arbitrary_command_list& co
1184
1204
cluster_mode ? m_totals.m_moved_sec : -1 ,
1185
1205
cluster_mode ? m_totals.m_ask_sec : -1 ,
1186
1206
m_totals.m_bytes_sec ,
1187
- quantile_list ,
1207
+ quantiles_list ,
1188
1208
m_totals.latency_histogram ,
1189
1209
timestamps,
1190
1210
total_stats
@@ -1327,7 +1347,7 @@ void run_stats::print(FILE *out, benchmark_config *config,
1327
1347
jsonhandler->open_nesting (" UNKNOWN STATS" );
1328
1348
}
1329
1349
1330
- print_json (jsonhandler, *config->arbitrary_commands , config->cluster_mode , config-> print_percentiles . quantile_list );
1350
+ print_json (jsonhandler, *config->arbitrary_commands , config->cluster_mode );
1331
1351
}
1332
1352
1333
1353
if (!config->hide_histogram ) {
0 commit comments