From 2f6f3941984aeec7b0ee1d928e23d458fa4809ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Fri, 6 Apr 2012 12:44:27 +0200 Subject: Add benchmark test. --- .../com/orbekk/protobuf/ProtobufFunctionalTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java b/src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java index 9e599a4..aa2eea0 100644 --- a/src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java +++ b/src/test/java/com/orbekk/protobuf/ProtobufFunctionalTest.java @@ -71,6 +71,27 @@ public class ProtobufFunctionalTest { } } + @org.junit.Test public void testNewRpcChannel() throws Exception { + NewRpcChannel channel = NewRpcChannel.create("localhost", serverport); + Test.Service service = Test.Service.newStub(channel); + Test.Type1 request = Test.Type1.newBuilder().build(); + int count = 1000000; + final Rpc rpc = new Rpc(); + final CountDownLatch stop = new CountDownLatch(count); + long startTime = System.currentTimeMillis(); + for (int i = 0; i < count; i++) { + service.testA(rpc, request, new RpcCallback() { + @Override public void run(Type2 result) { + stop.countDown(); + } + }); + } + stop.await(); + long elapsedTime = System.currentTimeMillis() - startTime; + System.out.println("Elapsed time for " + count + " requests: " + + elapsedTime + ". " + count/elapsedTime*1000 + "r/s"); + } + @org.junit.Test public void respondsNormally() throws Exception { Test.Type1 request = Test.Type1.newBuilder().build(); int count = 10; -- cgit v1.2.3