update testcase

This commit is contained in:
ehlxr 2018-08-15 10:40:37 +08:00
parent 538f42181f
commit 00f9e3efab
2 changed files with 50 additions and 57 deletions

View File

@ -1,50 +0,0 @@
package cn.ceres.did;
import cn.ceres.did.client.SdkClient;
import cn.ceres.did.sdk.SdkProto;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 同步请求压测
*
* @author ehlxr
*/
public class DidSdkPressSyncTest {
private static final Logger logger = LoggerFactory.getLogger(DidSdkPressSyncTest.class);
private static int NUM = 60000;
@Test
public void pressSyncTest() throws Exception {
SdkClient client = new SdkClient("10.19.248.200",30581);
client.init();
client.start();
long start;
long end;
long cast;
long amount = 0;
long allcast = 0;
for (int k = 0; k < 20; k++) {
start = System.currentTimeMillis();
for (int i = 0; i < NUM; i++) {
final SdkProto sdkProto = new SdkProto();
client.invokeSync(sdkProto, 5000);
}
end = System.currentTimeMillis();
cast = (end - start);
allcast += cast;
logger.info("invokeSync test num is: {}, cast time: {} millsec, throughput: {} send/millsec", NUM, cast, (double) NUM / cast);
amount += NUM;
// NUM += 5000;
// TimeUnit.SECONDS.sleep(2);
}
logger.info("invokeSync test all num is: {}, all cast time: {} millsec, all throughput: {} send/millsec", amount, allcast, (double) amount / allcast);
}
}

View File

@ -4,6 +4,8 @@ import cn.ceres.did.client.InvokeCallback;
import cn.ceres.did.client.ResponseFuture;
import cn.ceres.did.client.SdkClient;
import cn.ceres.did.sdk.SdkProto;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -15,17 +17,26 @@ import java.util.concurrent.CountDownLatch;
*
* @author ehlxr
*/
public class DidSdkPressAsyncTest {
private static final Logger logger = LoggerFactory.getLogger(DidSdkPressAsyncTest.class);
// 初始发送总量
private static int NUM = 80000;
public class DidSdkPressTest {
private static final Logger logger = LoggerFactory.getLogger(DidSdkPressTest.class);
private SdkClient client;
@Test
public void pressAsyncTest() throws Exception {
SdkClient client = new SdkClient("10.19.248.200",30581);
@Before
public void init() {
client = new SdkClient("10.19.248.200",30581);
// client = new SdkClient();
client.init();
client.start();
}
@After
public void destroy() {
client.shutdown();
}
@Test
public void asyncTest() throws Exception {
long start;
long end;
long cast;
@ -33,6 +44,8 @@ public class DidSdkPressAsyncTest {
long allcast = 0;
for (int k = 0; k < 10; k++) {
// 初始发送总量
int NUM = 80000;
final CountDownLatch countDownLatch = new CountDownLatch(NUM);
start = System.currentTimeMillis();
for (int i = 0; i < NUM; i++) {
@ -59,4 +72,34 @@ public class DidSdkPressAsyncTest {
logger.info("invokeAsync test all num is: {}, all cast time: {} millsec, all throughput: {} send/millsec", amount, allcast, (double) amount / allcast);
}
@Test
public void syncTest() throws Exception {
long start;
long end;
long cast;
long amount = 0;
long allcast = 0;
for (int k = 0; k < 20; k++) {
start = System.currentTimeMillis();
int NUM = 60000;
for (int i = 0; i < NUM; i++) {
final SdkProto sdkProto = new SdkProto();
client.invokeSync(sdkProto, 5000);
}
end = System.currentTimeMillis();
cast = (end - start);
allcast += cast;
logger.info("invokeSync test num is: {}, cast time: {} millsec, throughput: {} send/millsec", NUM, cast, (double) NUM / cast);
amount += NUM;
// NUM += 5000;
// TimeUnit.SECONDS.sleep(2);
}
logger.info("invokeSync test all num is: {}, all cast time: {} millsec, all throughput: {} send/millsec", amount, allcast, (double) amount / allcast);
}
}