From caab226eac919c2de63779a7ab5ec1b8122810bd Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Fri, 16 Apr 2021 14:50:00 +0800 Subject: [PATCH] =?UTF-8?q?IOT=E8=B0=83=E7=94=A8=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iotgateway/server/IotCommunication.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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());