update testcase
parent
538f42181f
commit
00f9e3efab
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,6 +4,8 @@ import cn.ceres.did.client.InvokeCallback;
|
||||||
import cn.ceres.did.client.ResponseFuture;
|
import cn.ceres.did.client.ResponseFuture;
|
||||||
import cn.ceres.did.client.SdkClient;
|
import cn.ceres.did.client.SdkClient;
|
||||||
import cn.ceres.did.sdk.SdkProto;
|
import cn.ceres.did.sdk.SdkProto;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -15,17 +17,26 @@ import java.util.concurrent.CountDownLatch;
|
||||||
*
|
*
|
||||||
* @author ehlxr
|
* @author ehlxr
|
||||||
*/
|
*/
|
||||||
public class DidSdkPressAsyncTest {
|
public class DidSdkPressTest {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DidSdkPressAsyncTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(DidSdkPressTest.class);
|
||||||
// 初始发送总量
|
private SdkClient client;
|
||||||
private static int NUM = 80000;
|
|
||||||
|
|
||||||
@Test
|
@Before
|
||||||
public void pressAsyncTest() throws Exception {
|
public void init() {
|
||||||
SdkClient client = new SdkClient("10.19.248.200",30581);
|
client = new SdkClient("10.19.248.200",30581);
|
||||||
|
// client = new SdkClient();
|
||||||
client.init();
|
client.init();
|
||||||
client.start();
|
client.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void destroy() {
|
||||||
|
client.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void asyncTest() throws Exception {
|
||||||
long start;
|
long start;
|
||||||
long end;
|
long end;
|
||||||
long cast;
|
long cast;
|
||||||
|
@ -33,6 +44,8 @@ public class DidSdkPressAsyncTest {
|
||||||
long allcast = 0;
|
long allcast = 0;
|
||||||
|
|
||||||
for (int k = 0; k < 10; k++) {
|
for (int k = 0; k < 10; k++) {
|
||||||
|
// 初始发送总量
|
||||||
|
int NUM = 80000;
|
||||||
final CountDownLatch countDownLatch = new CountDownLatch(NUM);
|
final CountDownLatch countDownLatch = new CountDownLatch(NUM);
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
for (int i = 0; i < NUM; i++) {
|
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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue