dubboとS-HSFテストの比較

4074 ワード

今日は大丈夫です.RPCフレームワークの性能を簡単にテストします.HSFはdubboに完勝しました.
1.dubboテスト結果:
消費時間:16.808 s
平均:0.16808 ms
TPS:5949.547834364588
テストデータ:


public class TPS_TEST {

    public static void main(String[] args) throws InterruptedException {
    	final ClassPathXmlApplicationContext context = 
    			new ClassPathXmlApplicationContext(
    					new String[] {"file:E:/1-project_test/dubbox-master/dubbo-demo/dubbo-demo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml"});
		final HelloService helloService = (HelloService)context.getBean("helloService"); // get service invocation proxy
    	ExecutorService executorServicePool = Executors.newFixedThreadPool(200);
    	final int size = 100000;
    	final CountDownLatch cdl = new CountDownLatch(size);
    	long begin = System.currentTimeMillis();
		for (int i = 0; i < size; i++) {
			executorServicePool.execute(new Runnable() {
				@Override
				public void run() {
					try {
						
						String hello = helloService.hello("aa"); // do invoke!
						//System.out.println( hello ); // cool, how are you~
				        cdl.countDown();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			});
		}
		//executorServicePool.shutdown();
		//executorService.awaitTermination(10, TimeUnit.MINUTES);
		cdl.await();// 
        long time = System.currentTimeMillis() - begin;
        System.out.println(" :" + (double) time / 1000 + " s");
        System.out.println(" :" + ((double) time) / size +" ms");
        System.out.println("TPS:" + (double) size / ((double) time / 1000));              
   
    
    }

   
}


2.hsfテスト結果:
消費時間:6.305 s
平均:0.06305 ms
TPS:15860.428231562253
テストデータ:


public class Client {
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		final int size = 100000;
		final CountDownLatch cdl = new CountDownLatch(size);

		// final TestService testService = ServiceProxyFactory.getRoundFactoryInstance(connector).wrapAsyncProxy(
		// TestService.class);
		
		HsfConnector connector = new HsfConnectorImpl();
		connector.connect(new InetSocketAddress("localhost", 8082));
		
		
		final TestService testService = ServiceProxyFactory.getRoundFactoryInstance(connector).wrapAsyncCallbackProxy(
				TestService.class, new AsyncCallback<Object>() {
					public void doCallback(Object data) {
						//System.out.println("received:" + data);
						cdl.countDown();
					};
					@Override
					public void doExceptionCaught(Throwable ex, HsfChannel channel, Object param) {
						System.out.println(ex);
						super.doExceptionCaught(ex, channel, param);
					}
				});
		ExecutorService executorServicePool = Executors.newFixedThreadPool(200);
		long begin = System.currentTimeMillis();
		for (int i = 0; i < size; i++) {
			executorServicePool.execute(new Runnable() {
				@Override
				public void run() {
					try {
						testService.test("aa");
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			});
		}
		//executorServicePool.shutdown();
		//executorService.awaitTermination(10, TimeUnit.MINUTES);
		cdl.await();// 
        long time = System.currentTimeMillis() - begin;
        System.out.println(" :" + (double) time / 1000 + " s");
        System.out.println(" :" + ((double) time) / size +" ms");
        System.out.println("TPS:" + (double) size / ((double) time / 1000));
        
	}

}