Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GRPC
- public RouteGuideClient(ManagedChannelBuilder<?> channelBuilder) {
- channel = channelBuilder.build();
- blockingStub = RouteGuideGrpc.newBlockingStub(channel);
- asyncStub = RouteGuideGrpc.newStub(channel);
- }
- RouteGuideClient client = new RouteGuideClient("localhost", 8980);
- try {
- final long startTime = System.nanoTime();
- for (int i = 0; i < 10000; i++)
- client.getFeature(409146138, -746188906);
- final long endTime = System.nanoTime();
- info("method 1 : " + (endTime - startTime));
- }
- public void getFeature(int lat, int lon) {
- try {
- Point request = Point.newBuilder().setLatitude(lat).setLongitude(lon).build();
- Feature feature = blockingStub.getFeature(request);
- } catch (RuntimeException e) {
- logger.log(Level.WARNING, "RPC failed", e);
- throw e;
- }
- }
- //Thrift
- int diff;
- Transport transport = new TSocket("localhost", 9090);
- transport.open();
- TProtocol protocol = new TBinaryProtocol(transport);
- MultiplicationService.Client client = new MultiplicationService.Client(protocol);
- final long startTime = System.nanoTime();
- try {
- for (int i = 0; i < 10000; i++)
- diff = client.calculate(i, i);
- } catch (InvalidOperation io) {
- System.out.println("Invalid operation: " + io.why);
- }
- final long endTime = System.nanoTime();
- System.out.println("method 1 : " + (endTime - startTime));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement