@@ -214,31 +214,32 @@ public PrintlnStats(String testID, long interval,
214
214
215
215
@ Override
216
216
protected void report (long now ) {
217
- System . out . print ( "id: " + testID + ", " ) ;
217
+ String output = "id: " + testID + ", " ;
218
218
219
- System .out .print ("time: " + String .format ("%.3f" , (now - startTime )/1000.0 ) + "s" );
219
+ output += "time: " + String .format ("%.3f" , (now - startTime )/1000.0 ) + "s" ;
220
+ output +=
221
+ showRate ("sent" , sendCountInterval , sendStatsEnabled , elapsedInterval ) +
222
+ showRate ("returned" , returnCountInterval , sendStatsEnabled && returnStatsEnabled , elapsedInterval ) +
223
+ showRate ("confirmed" , confirmCountInterval , sendStatsEnabled && confirmStatsEnabled , elapsedInterval ) +
224
+ showRate ("nacked" , nackCountInterval , sendStatsEnabled && confirmStatsEnabled , elapsedInterval ) +
225
+ showRate ("received" , recvCountInterval , recvStatsEnabled , elapsedInterval );
220
226
221
- showRate ("sent" , sendCountInterval , sendStatsEnabled , elapsedInterval );
222
- showRate ("returned" , returnCountInterval , sendStatsEnabled && returnStatsEnabled , elapsedInterval );
223
- showRate ("confirmed" , confirmCountInterval , sendStatsEnabled && confirmStatsEnabled , elapsedInterval );
224
- showRate ("nacked" , nackCountInterval , sendStatsEnabled && confirmStatsEnabled , elapsedInterval );
225
- showRate ("received" , recvCountInterval , recvStatsEnabled , elapsedInterval );
226
-
227
- System .out .print ((latencyCountInterval > 0 ?
227
+ output += (latencyCountInterval > 0 ?
228
228
", min/avg/max latency: " +
229
229
minLatency /1000L + "/" +
230
230
cumulativeLatencyInterval / (1000L * latencyCountInterval ) + "/" +
231
231
maxLatency /1000L + " microseconds" :
232
- "" )) ;
232
+ "" );
233
233
234
- System .out .println ();
234
+ System .out .println (output );
235
235
}
236
236
237
- private void showRate (String descr , long count , boolean display ,
237
+ private String showRate (String descr , long count , boolean display ,
238
238
long elapsed ) {
239
- if (display ) {
240
- System .out .print (", " + descr + ": " + formatRate (1000.0 * count / elapsed ) + " msg/s" );
241
- }
239
+ if (display )
240
+ return ", " + descr + ": " + formatRate (1000.0 * count / elapsed ) + " msg/s" ;
241
+ else
242
+ return "" ;
242
243
}
243
244
244
245
public void printFinal () {
0 commit comments