1010import java .io .IOException ;
1111import java .util .Random ;
1212
13+ import org .apache .commons .cli .CommandLine ;
14+ import org .apache .commons .cli .CommandLineParser ;
15+ import org .apache .commons .cli .GnuParser ;
16+ import org .apache .commons .cli .HelpFormatter ;
17+ import org .apache .commons .cli .Option ;
18+ import org .apache .commons .cli .Options ;
19+ import org .apache .commons .cli .ParseException ;
20+
1321/**
1422 * Class to explore how performance of sending and receiving messages varies with the buffer size and
1523 * enabling/disabling Nagle's algorithm.
@@ -26,10 +34,15 @@ public class BufferPerformanceMetrics{
2634 public static final int PEAK_SIZE = 20 * 1024 ;
2735
2836 public static void main (String [] args ) throws Exception {
37+ String hostName = args .length > 0 ? args [0 ] : "localhost" ;
38+
2939 Random rnd = new Random ();
3040
3141 System .out .println ("buffer size, publish rate with nagle, get rate with nagle," +
3242 " publish rate without nagle, get rate without nagle" );
43+
44+
45+
3346 for (int repeat = 0 ; repeat < REPEATS ; repeat ++){
3447 final int bufferSize = 1 + rnd .nextInt (PEAK_SIZE );
3548
@@ -43,7 +56,8 @@ public static void main(String[] args) throws Exception{
4356 socket .setSendBufferSize (bufferSize );
4457 }
4558 };
46- Connection connection = factory .newConnection ("localhost" );
59+
60+ Connection connection = factory .newConnection (hostName );
4761 Channel channel = connection .createChannel ();
4862 channel .exchangeDeclare (EXCHANGE , "direct" );
4963 channel .queueDeclare (QUEUE );
0 commit comments