Skip to content

Commit 85de1ba

Browse files
author
David R. MacIver
committed
Add support to BufferPerformanceMetrics for connecting to a remote host.
1 parent 2afb433 commit 85de1ba

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/src/com/rabbitmq/examples/BufferPerformanceMetrics.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
import java.io.IOException;
1111
import 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

Comments
 (0)