private String buildRow(long n){
  ArrayList<Long> times=timings.get(n);
  long sum, min, max;
  if (times == null || times.size() == 0) {
    return n + ",*,*,*,*,0";
  }
  sum=0;
  min=max=sum=times.get(0);
  if (times.size() == 1) {
    return n + "," + min+ ","+ min+ ","+ max+ ","+ 0.0+ ","+ 1;
  }
  int minIdx=0;
  int maxIdx=0;
  for (int i=1; i < times.size(); i++) {
    long t=times.get(i);
    if (t < min) {
      min=t;
      minIdx=i;
    }
    if (t > max) {
      max=t;
      maxIdx=i;
    }
    sum+=t;
  }
  if (times.size() == 2) {
    double diff=Math.abs(max - min);
    diff=diff / 2;
    double avg=max + min;
    avg=avg / 2;
    return n + "," + avg+ ","+ min+ ","+ max+ ","+ diff+ ","+ 2;
  }
  sum=sum - min - max;
  int ct=times.size() - 2;
  double mean=sum;
  mean=mean / ct;
  double calc=0;
  for (int i=0; i < times.size(); i++) {
    if (i == minIdx || i == maxIdx)     continue;
    calc+=(times.get(i) - mean) * (times.get(i) - mean);
  }
  if (ct == 1) {
    calc=0;
  }
 else {
    calc/=(ct - 1);
    calc=Math.sqrt(calc);
  }
  return n + "," + mean+ ","+ min+ ","+ max+ ","+ calc+ ","+ ct;
}

private String buildRow ( long n ) { ArrayList < Long > times = timings . get ( n ) ; long sum , min , max ; if ( times == null || times . size ( ) == 0 ) { return n + ",*,*,*,*,0" ; } sum = 0 ; min = max = sum = times . get ( 0 ) ; if ( times . size ( ) == 1 ) { return n + "," + min + "," + min + "," + max + "," + 0.0 + "," + 1 ; } int minIdx = 0 ; int maxIdx = 0 ; for ( int i = 1 ; i < times . size ( ) ; i ++ ) { long t = times . get ( i ) ; if ( t < min ) { min = t ; minIdx = i ; } if ( t > max ) { max = t ; maxIdx = i ; } sum += t ; } if ( times . size ( ) == 2 ) { double diff = Math . abs ( max - min ) ; diff = diff / 2 ; double avg = max + min ; avg = avg / 2 ; return n + "," + avg + "," + min + "," + max + "," + diff + "," + 2 ; } sum = sum - min - max ; int ct = times . size ( ) - 2 ; double mean = sum ; mean = mean / ct ; double calc = 0 ; for ( int i = 0 ; i < times . size ( ) ; i ++ ) { if ( i == minIdx || i == maxIdx ) continue ; calc += ( times . get ( i ) - mean ) * ( times . get ( i ) - mean ) ; } if ( ct == 1 ) { calc = 0 ; } else { calc /= ( ct - 1 ) ; calc = Math . sqrt ( calc ) ; } return n + "," + mean + "," + min + "," + max + "," + calc + "," + ct ; }
helper method to build row in table for given entry . always returns a string of six values separated by commas .
