package com.gaoli.impl; import com.gaoli.AccountQryRequest; import com.gaoli.AccountQryResponse; import com.gaoli.AccountQryServiceGrpc; import com.gaoli.AccountQryServiceGrpc.AccountQryServiceBlockingStub; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import java.io.IOException; public class Client { public static void main( String[] args ) throws IOException{ AccountQryRequest request = AccountQryRequest.newBuilder().setUserId("20012").setRequestId("123").build(); ManagedChannel channel = ManagedChannelBuilder .forAddress("localhost", 8883) .usePlaintext(true) .build(); AccountQryServiceBlockingStub stub = AccountQryServiceGrpc.newBlockingStub(channel); for (int j = 0; j < 20; j++) { long start = System.currentTimeMillis(); for(int i=0; i<10000; i++){ AccountQryResponse rsp = stub.qry(request); //System.out.println(rsp); } System.out.println(System.currentTimeMillis() - start + " MS"); } } }