private void printDurationStatistics(Map<Integer,Long> deliveryDurations,Map<Integer,Long> sndDurations,int maxMsgId,long guessedMaxDuration){
  DurationAccumulator overall=new DurationAccumulator();
  DurationAccumulator[] msgRange=collectStatistics(deliveryDurations,overall,maxMsgId);
  int[] durationRange=new int[STATISTICS_SEGMENTS_CNT];
  for (  Map.Entry<Integer,Long> e : deliveryDurations.entrySet()) {
    long duration=e.getValue();
    int idx=(int)((duration - 1) * durationRange.length / guessedMaxDuration);
    if (idx < 0)     idx=0;
    if (idx >= durationRange.length)     idx=durationRange.length - 1;
    durationRange[idx]++;
  }
  DurationAccumulator sndOverall=new DurationAccumulator();
  DurationAccumulator[] sndRange=collectStatistics(sndDurations,sndOverall,maxMsgId);
  info("Overall send statistics: " + sndOverall);
  info("Per message id statistics:");
  for (int i=0; i < sndRange.length; i++) {
    int rangeMin=i * maxMsgId / sndRange.length + 1;
    int rangeMax=(i + 1) * maxMsgId / sndRange.length;
    info(">>> [" + rangeMin + '-'+ rangeMax+ "]: "+ sndRange[i]);
  }
  info("Overall duration statistics: " + overall);
  info("Per message id statistics:");
  for (int i=0; i < msgRange.length; i++) {
    int rangeMin=i * maxMsgId / msgRange.length + 1;
    int rangeMax=(i + 1) * maxMsgId / msgRange.length;
    info(">>> [" + rangeMin + '-'+ rangeMax+ "]: "+ msgRange[i]);
  }
  info("Duration histogram:");
  for (int i=0; i < msgRange.length; i++) {
    int rangeMin=(int)(i * guessedMaxDuration / durationRange.length + 1);
    int rangeMax=(int)((i + 1) * guessedMaxDuration / durationRange.length);
    float percents=(float)durationRange[i] * 100 / overall.count();
    info(">>> [" + rangeMin + '-'+ rangeMax+ "] ms: "+ String.format("%.2f",percents)+ "% ("+ durationRange[i]+ " messages)");
  }
}

private void printDurationStatistics ( Map < Integer , Long > deliveryDurations , Map < Integer , Long > sndDurations , int maxMsgId , long guessedMaxDuration ) { DurationAccumulator overall = new DurationAccumulator ( ) ; DurationAccumulator [ ] msgRange = collectStatistics ( deliveryDurations , overall , maxMsgId ) ; int [ ] durationRange = new int [ STATISTICS_SEGMENTS_CNT ] ; for ( Map . Entry < Integer , Long > e : deliveryDurations . entrySet ( ) ) { long duration = e . getValue ( ) ; int idx = ( int ) ( ( duration - 1 ) * durationRange . length / guessedMaxDuration ) ; if ( idx < 0 ) idx = 0 ; if ( idx >= durationRange . length ) idx = durationRange . length - 1 ; durationRange [ idx ] ++ ; } DurationAccumulator sndOverall = new DurationAccumulator ( ) ; DurationAccumulator [ ] sndRange = collectStatistics ( sndDurations , sndOverall , maxMsgId ) ; info ( "Overall send statistics: " + sndOverall ) ; info ( "Per message id statistics:" ) ; for ( int i = 0 ; i < sndRange . length ; i ++ ) { int rangeMin = i * maxMsgId / sndRange . length + 1 ; int rangeMax = ( i + 1 ) * maxMsgId / sndRange . length ; info ( ">>> [" + rangeMin + '-' + rangeMax + "]: " + sndRange [ i ] ) ; } info ( "Overall duration statistics: " + overall ) ; info ( "Per message id statistics:" ) ; for ( int i = 0 ; i < msgRange . length ; i ++ ) { int rangeMin = i * maxMsgId / msgRange . length + 1 ; int rangeMax = ( i + 1 ) * maxMsgId / msgRange . length ; info ( ">>> [" + rangeMin + '-' + rangeMax + "]: " + msgRange [ i ] ) ; } info ( "Duration histogram:" ) ; for ( int i = 0 ; i < msgRange . length ; i ++ ) { int rangeMin = ( int ) ( i * guessedMaxDuration / durationRange . length + 1 ) ; int rangeMax = ( int ) ( ( i + 1 ) * guessedMaxDuration / durationRange . length ) ; float percents = ( float ) durationRange [ i ] * 100 / overall . count ( ) ; info ( ">>> [" + rangeMin + '-' + rangeMax + "] ms: " + String . format ( "%.2f" , percents ) + "% (" + durationRange [ i ] + " messages)" ) ; } }
prints statistics on message delivery duration time .
