}
public Results run() throws Exception{
Connection con = new ConnectionFactory(){{setHost(params.host); setPort(params.port);}}.newConnection();
Channel channel = con.createChannel();
Results r = new Results(params.maxBindingExp);
for (int y = 0; y < params.maxBindingExp; y++) {
final int maxBindings = pow(params.base, y);
String[] routingKeys = new String[maxBindings];
for (int b = 0; b < maxBindings; b++) {
routingKeys[b] = UUID.randomUUID().toString();
}
Stack<String> queues = new Stack<String>();
int maxQueueExp = Math.min(params.maxQueueExp, params.maxExp - y);
System.out.println("---------------------------------");
System.out.println("| bindings = " + maxBindings + ", messages = " + params.messageCount);
System.out.println("| Routing");
int q = 0;
// create queues & bindings, time routing
Measurements creation = new CreationMeasurements(maxQueueExp);
float routingTimes[] = new float[maxQueueExp];
for (int x = 0; x < maxQueueExp; x++) {
final int maxQueues = pow(params.base, x);
for (; q < maxQueues; q++) {
AMQP.Queue.DeclareOk ok = channel.queueDeclare();
queues.push(ok.getQueue());
for (int b = 0; b < maxBindings; b++) {
channel.queueBind(ok.getQueue(), "amq.direct", routingKeys[b]);
}
}
creation.addDataPoint(x);
float routingTime = timeRouting(channel, routingKeys);
routingTimes[x] = routingTime;
printTime(params.base, x, routingTime);
}
r.routingTimes[y] = routingTimes;
float[] creationTimes = creation.analyse(params.base);
r.creationTimes[y] = creationTimes;
System.out.println("| Creating");
printTimes(params.base, creationTimes);
// delete queues & bindings
Measurements deletion = new DeletionMeasurements(maxQueueExp);
for (int x = maxQueueExp - 1; x >= 0; x--) {
final int maxQueues = (x == 0) ? 0 : pow(params.base, x - 1);
for (; q > maxQueues; q--) {
channel.queueDelete(queues.pop());
}
deletion.addDataPoint(x);
}
float[] deletionTimes = deletion.analyse(params.base);
r.deletionTimes[y] = deletionTimes;
System.out.println("| Deleting");
printTimes(params.base, deletionTimes);
}
channel.close();
con.close();
return r;
}