Methods Summary |
---|
public void | bytesRead(int num_bytes_read)
total_reads++;
updateSizes( read_sizes, num_bytes_read );
|
public void | bytesWritten(int num_bytes_written)
total_writes++;
updateSizes( write_sizes, num_bytes_written );
|
private void | printSizes(java.util.TreeMap size_map, long num_total)
int prev_high = 1;
for( Iterator it = size_map.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry)it.next();
int key = ((Integer)entry.getKey()).intValue();
long count = ((Long)entry.getValue()).longValue();
long percentage = (count *100) / num_total;
if( key == 0 ) {
if( percentage > 3 ) {
System.out.println( "[0 bytes]= x" +percentage+ "%" );
}
}
else {
int high = key * GRANULARITY;
if( percentage > 3 ) {
System.out.println( "[" +prev_high+ "-" +(high -1)+ " bytes]= x" +percentage+ "%" );
}
prev_high = high;
}
}
|
private void | printStats()
System.out.println( "\n------------------------------" );
System.out.println( "***** TCP SOCKET READ SIZE STATS *****" );
printSizes( read_sizes, total_reads );
System.out.println( "\n***** TCP SOCKET WRITE SIZE STATS *****" );
printSizes( write_sizes, total_writes );
System.out.println( "------------------------------" );
|
private void | updateSizes(java.util.TreeMap io_sizes, int num_bytes)
Integer size_key;
if( num_bytes == 0 ) {
size_key = new Integer( 0 );
}
else {
size_key = new Integer( (num_bytes / GRANULARITY) +1 );
}
Long count = (Long)io_sizes.get( size_key );
if( count == null ) {
io_sizes.put( size_key, new Long( 1 ) );
}
else {
io_sizes.put( size_key, new Long( count.longValue() +1 ) );
}
|