diff --git a/src/main/java/com/telpo/iotgateway/server/IotCommunication.java b/src/main/java/com/telpo/iotgateway/server/IotCommunication.java index 9f4ebcf..5dc098f 100644 --- a/src/main/java/com/telpo/iotgateway/server/IotCommunication.java +++ b/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());