Skip to content

Commit c75fd1a

Browse files
author
Simon MacMullen
committed
Merge heads
2 parents 92ff66f + f2804ab commit c75fd1a

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void main(String[] args) {
4949
String exchangeName = strArg(cmd, 'e', exchangeType);
5050
String queueName = strArg(cmd, 'u', "");
5151
int samplingInterval = intArg(cmd, 'i', 1);
52-
int rateLimit = intArg(cmd, 'r', 0);
52+
float rateLimit = floatArg(cmd, 'r', 0.0f);
5353
int producerCount = intArg(cmd, 'x', 1);
5454
int consumerCount = intArg(cmd, 'y', 1);
5555
int producerTxSize = intArg(cmd, 'm', 0);
@@ -165,6 +165,10 @@ private static int intArg(CommandLine cmd, char opt, int def) {
165165
return Integer.parseInt(cmd.getOptionValue(opt, Integer.toString(def)));
166166
}
167167

168+
private static float floatArg(CommandLine cmd, char opt, float def) {
169+
return Float.parseFloat(cmd.getOptionValue(opt, Float.toString(def)));
170+
}
171+
168172
private static List<?> lstArg(CommandLine cmd, char opt) {
169173
String[] vals = cmd.getOptionValues('f');
170174
if (vals == null) {

test/src/com/rabbitmq/examples/perf/MulticastParams.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class MulticastParams {
3636
private int minMsgSize = 0;
3737

3838
private int timeLimit = 0;
39-
private int rateLimit = 0;
39+
private float rateLimit = 0;
4040
private int producerMsgCount = 0;
4141
private int consumerMsgCount = 0;
4242

@@ -65,7 +65,7 @@ public void setQueueName(String queueName) {
6565
this.queueName = queueName;
6666
}
6767

68-
public void setRateLimit(int rateLimit) {
68+
public void setRateLimit(float rateLimit) {
6969
this.rateLimit = rateLimit;
7070
}
7171

test/src/com/rabbitmq/examples/perf/Producer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Producer implements Runnable, ReturnListener,
4141
private boolean immediate;
4242
private boolean persistent;
4343
private int txSize;
44-
private int rateLimit;
44+
private float rateLimit;
4545
private int msgLimit;
4646
private long timeLimit;
4747

@@ -59,7 +59,7 @@ public class Producer implements Runnable, ReturnListener,
5959

6060
public Producer(Channel channel, String exchangeName, String id,
6161
List<?> flags, int txSize,
62-
int rateLimit, int msgLimit, int minMsgSize, int timeLimit,
62+
float rateLimit, int msgLimit, int minMsgSize, int timeLimit,
6363
long confirm, Stats stats)
6464
throws IOException {
6565

@@ -172,8 +172,8 @@ private void delay(long now)
172172
//10 ms have elapsed, we have sent 200 messages
173173
//the 200 msgs we have actually sent should have taken us
174174
//200 * 1000 / 5000 = 40 ms. So we pause for 40ms - 10ms
175-
long pause = rateLimit == 0 ?
176-
0 : (msgCount * 1000L / rateLimit - elapsed);
175+
long pause = (long) (rateLimit == 0.0f ?
176+
0.0f : (msgCount * 1000.0 / rateLimit - elapsed));
177177
if (pause > 0) {
178178
Thread.sleep(pause);
179179
}

0 commit comments

Comments
 (0)