林万龙 преди 3 години
родител
ревизия
caab226eac
променени са 1 файла, в които са добавени 19 реда и са изтрити 2 реда
  1. +19
    -2
      src/main/java/com/telpo/iotgateway/server/IotCommunication.java

+ 19
- 2
src/main/java/com/telpo/iotgateway/server/IotCommunication.java Целия файл

@@ -70,6 +70,10 @@ public class IotCommunication {

String ProductKey = "a18mXM6Cvx8";
String DeviceName = "800115470000678";
long reqCount = 0;
long reqLongCount = 0;
long allOfManTime = 0;
long appStartTime = (new DateTime()).getTime();

DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", accessKey, accessSecret);
IAcsClient client = new DefaultAcsClient(profile);
@@ -100,15 +104,28 @@ public class IotCommunication {
request.putQueryParameter("DeviceName", DeviceName);

long startTime = (new DateTime()).getTime();
log.debug("开始IOT请求");
//log.debug("开始IOT请求");
CommonResponse response = client.getCommonResponse(request);
long endTime = (new DateTime()).getTime();
long useTime = endTime-startTime;
log.debug("结束IOT请求, 用时:" + useTime);
allOfManTime = allOfManTime + useTime;
//log.debug("结束IOT请求, 用时:" + useTime);
Thread.sleep(10);
if (useTime > 2000) {
reqLongCount++;
log.debug(response.getData());
}
reqCount++;
if (reqCount == 10000) {
long appPassTime = (new DateTime()).getTime();
log.info("10000请求用时秒数:" + (appPassTime-appStartTime)/1000);
log.info("用时超过2秒次数:" + reqLongCount);
log.info("平均每次请求用时(毫秒):" + allOfManTime/10000);
reqCount = 0;
allOfManTime = 0;
appStartTime = appPassTime;
reqLongCount=0;
}
}
} catch (ServerException e) {
log.error("IllegalArgumentException:{}", e.getMessage());


Loading…
Отказ
Запис