usage(args);
}
}
TestClient[] client = new TestClient[clients];
WebSocketClient wsclient = new WebSocketClient(bufferPool);
try
{
wsclient.start();
__start = System.currentTimeMillis();
protocol = protocol == null?"echo":protocol;
for (int i = 0; i < clients; i++)
{
client[i] = new TestClient(wsclient,host,port,protocol,60000);
client[i].open();
}
System.out.println("Jetty WebSocket PING " + host + ":" + port + " (" + new InetSocketAddress(host,port) + ") " + clients + " clients " + protocol);
for (int p = 0; p < count; p++)
{
long next = System.currentTimeMillis() + delay;
byte op = OpCode.TEXT;
if (binary)
{
op = OpCode.BINARY;
}
byte data[] = null;
switch (op)
{
case OpCode.TEXT:
{
StringBuilder b = new StringBuilder();
while (b.length() < size)
{
b.append('A' + __random.nextInt(26));
}
data = b.toString().getBytes(StandardCharsets.UTF_8);
break;
}
case OpCode.BINARY:
{
data = new byte[size];
__random.nextBytes(data);
break;
}
}
for (int i = 0; i < clients; i++)
{
client[i].send(op,data,fragment);
}
while (System.currentTimeMillis() < next)
{
Thread.sleep(10);
}
}
}
finally
{
for (int i = 0; i < clients; i++)
{
if (client[i] != null)
{
client[i].disconnect();
}
}
long duration = System.currentTimeMillis() - __start;
System.out.println("--- " + host + " websocket ping statistics using " + clients + " connection" + (clients > 1?"s":"") + " ---");
System.out.printf("%d/%d frames sent/recv, %d/%d mesg sent/recv, time %dms %dm/s %.2fbps%n",__framesSent,__framesReceived.get(),__messagesSent,
__messagesReceived.get(),duration,((1000L * __messagesReceived.get()) / duration),(1000.0D * __messagesReceived.get() * 8 * size)
/ duration / 1024 / 1024);
System.out.printf("rtt min/ave/max = %.3f/%.3f/%.3f ms\n",__minDuration.get() / 1000000.0,__messagesReceived.get() == 0?0.0:(__totalTime.get()
/ __messagesReceived.get() / 1000000.0),__maxDuration.get() / 1000000.0);
wsclient.stop();
}
bufferPool.assertNoLeaks();
}