double bytesPerSecond ( double byteCount , double durationNano ) { if ( byteCount < 0 || durationNano < 0 ) throw new IllegalArgumentException ( ) ; if ( durationNano == 0 ) { durationNano = 1.0 ; // defend against division by zero if ( log . isDebugEnabled ( ) ) { log . debug ( "Set zero to one to avoid division by zero; but should never get here!" ) ; } } double bytesPerSec = ( byteCount / durationNano ) * NANO_PER_SEC ; if ( bytesPerSec == 0 ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "zero bytes per sec. Really ?" ) ; } } return bytesPerSec ; }
Returns the number of bytes per second given the byte count and duration in nano seconds . Duration of zero nanosecond will be treated as 1 nanosecond .