解决ios一台设备同时存在两个线程获取性能数据

master
yineng.huang 2024-07-12 11:51:49 +08:00
parent c2b8a98a2c
commit 3e36ba544c
2 changed files with 18 additions and 12 deletions

View File

@ -129,6 +129,7 @@ public class AndroidDebuggerServiceImpl extends AbstractDebuggerService {
androidDeviceInfoByPackageThread = new AndroidDeviceInfoByPackageThread(info); androidDeviceInfoByPackageThread = new AndroidDeviceInfoByPackageThread(info);
androidDeviceInfoByPackageThread.start(); androidDeviceInfoByPackageThread.start();
queryDeviceInfoByPackageMap.put(info.getDeviceId(), androidDeviceInfoByPackageThread); queryDeviceInfoByPackageMap.put(info.getDeviceId(), androidDeviceInfoByPackageThread);
logger.debug("记录设备【{}】的应用的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
AndroidDeviceAllInfoThread androidDeviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId()); AndroidDeviceAllInfoThread androidDeviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId());
if (androidDeviceAllInfoThread != null ) { if (androidDeviceAllInfoThread != null ) {
logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId()); logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
@ -139,6 +140,7 @@ public class AndroidDebuggerServiceImpl extends AbstractDebuggerService {
androidDeviceAllInfoThread = new AndroidDeviceAllInfoThread(info); androidDeviceAllInfoThread = new AndroidDeviceAllInfoThread(info);
androidDeviceAllInfoThread.start(); androidDeviceAllInfoThread.start();
queryDeviceInfoMap.put(info.getCaseId(), androidDeviceAllInfoThread); queryDeviceInfoMap.put(info.getCaseId(), androidDeviceAllInfoThread);
logger.debug("记录设备【{}】的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
return true; return true;
} }

View File

@ -338,23 +338,27 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService {
@Override @Override
public boolean recordDevicePer(DebuggerDeviceInfo info) { public boolean recordDevicePer(DebuggerDeviceInfo info) {
IOSDeviceInfoByPackageThread iosDeviceInfoByPackageThread = queryDeviceInfoByPackageMap.get(info.getCaseId()); IOSDeviceInfoByPackageThread iosDeviceInfoByPackageThread = queryDeviceInfoByPackageMap.get(info.getCaseId());
if (null == iosDeviceInfoByPackageThread || !iosDeviceInfoByPackageThread.isAlive() || iosDeviceInfoByPackageThread.isInterrupted()) { if (null != iosDeviceInfoByPackageThread) {
logger.debug("开始记录任务id【{}】的应用的参数。。。。。。。。。。", info.getCaseId()); logger.debug("记录设备【{}】的应用的性能在任务【{}】中已经存在,干掉上一个。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
iosDeviceInfoByPackageThread.stopThread();
} else {
logger.debug("记录设备【{}】的应用的性能线程不存在。。。。。。。。。。", info.getDeviceId());
}
iosDeviceInfoByPackageThread = new IOSDeviceInfoByPackageThread(info); iosDeviceInfoByPackageThread = new IOSDeviceInfoByPackageThread(info);
iosDeviceInfoByPackageThread.start(); iosDeviceInfoByPackageThread.start();
queryDeviceInfoByPackageMap.put(info.getCaseId(), iosDeviceInfoByPackageThread); queryDeviceInfoByPackageMap.put(info.getCaseId(), iosDeviceInfoByPackageThread);
} else { logger.debug("记录设备【{}】的应用的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
logger.debug("任务id【{}】的应用的参数线程存在,无需创建。。。。。。。。。。", info.getCaseId());
}
IOSDeviceAllInfoThread deviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId()); IOSDeviceAllInfoThread deviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId());
if (null == deviceAllInfoThread || !deviceAllInfoThread.isAlive() || deviceAllInfoThread.isInterrupted()) { if (null != deviceAllInfoThread) {
logger.debug("开始记录任务id【{}】的设备的参数。。。。。。。。。。", info.getCaseId()); logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
deviceAllInfoThread.stopThread();
} else {
logger.debug("记录设备【{}】性能线程不存在。。。。。。。。。。", info.getDeviceId());
}
deviceAllInfoThread = new IOSDeviceAllInfoThread(info,iosDeviceInfoByPackageThread.getDeviceCpuNum()); deviceAllInfoThread = new IOSDeviceAllInfoThread(info,iosDeviceInfoByPackageThread.getDeviceCpuNum());
deviceAllInfoThread.start(); deviceAllInfoThread.start();
queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread); queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread);
} else { logger.debug("记录设备【{}】的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
logger.debug("任务id【{}】的设备的参数线程存在,无需创建。。。。。。。。。。", info.getCaseId());
}
return true; return true;
} }
} }