use of com.tencent.wstt.gt.OutPara in project GT by Tencent.
the class GTAutoTestInternal method endProcTest.
/**
* 停止指定被测应用的数据采集
* @param pkgName 指定的被测应用,目前不使用
* @param pid 被测应用指定的被测进程,目前不使用,会同时采集应用的所有进程
* @param saveFolderName 采集的被测数据保存目录名 sdcard/GT/GW/default/{saveFolderName}
* @param clear 是否清理历史记录
*/
public static void endProcTest(String pkgName, int pid, String path, String desc, boolean clear) {
// 结束统计,避免保存时候有风险
OpUIManager.gw_running = false;
// 保存之前要把关注的出参置为可保存的状态,因为保存前有些出参可能置为不记录状态
for (List<OutPara> ops : tempMap.values()) {
if (ops != null) {
for (OutPara op : ops) {
// 只有monitor状态下才会保存,和手工操作一样
op.setMonitor(true);
}
}
}
// 保存
String path1 = null;
String path2 = null;
String path3 = null;
if (path != null && !path.isEmpty()) {
String[] paths = path.split(FileUtil.separator);
if (paths.length > 2) {
// 倒数第三级目录
path1 = paths[paths.length - 3];
// 倒数第二级目录
path2 = paths[paths.length - 2];
// 最后一级目录
path3 = paths[paths.length - 1];
} else if (paths.length == 2) {
// 倒数第二级目录
path2 = paths[paths.length - 2];
// 最后一级目录
path3 = paths[paths.length - 1];
} else {
path3 = paths[0];
}
}
if (null == path1 || path1.equals("")) {
path1 = Env.CUR_APP_NAME;
}
if (null == path2 || path2.equals("")) {
path2 = Env.CUR_APP_VER;
}
if (null == path3 || path3.equals("")) {
path3 = GTGWInternal.getLastSaveFolder();
}
GWSaveEntry saveEntry = new GWSaveEntry(path1, path2, path3, desc);
GTGWInternal.saveAllEnableGWData(saveEntry);
if (clear) {
// 1.清空老数据
GTGWInternal.clearAllEnableGWData();
}
// 2.保存后要把所有出参置为非monitor状态
for (List<OutPara> ops : tempMap.values()) {
if (ops != null) {
for (OutPara op : ops) {
// 只有monitor状态下才会保存,和手工操作一样
op.setMonitor(false);
}
}
}
if (clear) {
// 3.清理旧记录
tempMap.clear();
}
// 通知AUT页同步状态
GTApp.getAUTHandler().sendEmptyMessage(0);
}
use of com.tencent.wstt.gt.OutPara in project GT by Tencent.
the class ProcPerfParaRunEngine method getCurEnableProcPerfParas.
private List<OutPara> getCurEnableProcPerfParas() {
Client client = ClientManager.getInstance().getAUTClient();
if (client == null) {
return EMPTY_LIST;
}
List<OutPara> ops = ClientManager.getInstance().getAUTClient().getAllOutParas();
enable_procPerf_ops.clear();
for (OutPara op : ops) {
if (OutPara.DISPLAY_DISABLE != op.getDisplayProperty()) {
enable_procPerf_ops.add(op);
}
}
return enable_procPerf_ops;
}
use of com.tencent.wstt.gt.OutPara in project GT by Tencent.
the class ProcPerfParaRunEngine method getProcPerfParasValue.
private String getProcPerfParasValue(OutPara op) {
String value = "";
try {
int size = AUTManager.pIds.length;
for (int i = 0; i < size; i++) {
if (!ProcessUtils.isProcessAlive(AUTManager.pIds[i])) {
value = "";
break;
}
if (op.getKey().contains(CommonString.pcpu_key + i + ":" + AUTManager.pNames[i])) {
value = CpuUtils.cpuInfoMap.get(CommonString.pcpu_key + i + ":" + AUTManager.pNames[i]).getProcessCpuUsage(Integer.valueOf(AUTManager.pIds[i]));
long tempValue = Double.valueOf((Double.valueOf(value.substring(0, value.length() - 1)) * 100)).longValue();
OpPerfBridge.addHistory(op, value, tempValue);
return value;
} else if (op.getKey().contains(CommonString.pjif_key + i + ":" + AUTManager.pNames[i])) {
// 如果需要刷新的列表中也包含对应进程的CPU,那不需要重复刷CPU值了
String tempCpuKey = CommonString.pcpu_key + i + ":" + AUTManager.pNames[i];
boolean hasCpuObservered = false;
for (OutPara opTemp : enable_procPerf_ops) {
if (opTemp.getKey().equals(tempCpuKey)) {
hasCpuObservered = true;
break;
}
}
if (!hasCpuObservered) {
CpuUtils.cpuInfoMap.get(tempCpuKey).getProcessCpuUsage(Integer.valueOf(AUTManager.pIds[i]));
}
long tempValue = CpuUtils.cpuInfoMap.get(tempCpuKey).getJif();
value = String.valueOf(tempValue);
OpPerfBridge.addHistory(op, value, tempValue);
return value;
} else if (op.getKey().contains(CommonString.pnet_key)) {
String pName = AUTManager.pkn.toString();
NetUtils netUtils = NetUtils.netInfoMap.get(pName);
// 实际使用时候发现,收发的数据分成两条曲线最合理
double lastT = netUtils.getP_t_add();
double lastR = netUtils.getP_r_add();
value = netUtils.getProcessNetValue(pName);
double nowT = netUtils.getP_t_add();
double nowR = netUtils.getP_r_add();
// modify on 20120616 过滤有的手机进程流量偶尔输出负数的情况
if ((nowT != lastT || nowR != lastR) && nowT >= 0 && nowR >= 0) {
OpPerfBridge.addHistory(op, value, new long[] { (long) nowT, (long) nowR });
}
return value;
} else if (op.getKey().equals(CommonString.pm_pss_key + i + ":" + AUTManager.pNames[i])) {
long[] long_value = MemUtils.getPSS(GTApp.getContext(), Integer.parseInt(AUTManager.pIds[i]));
long tmp = long_value[0];
long_value[0] = long_value[2];
long_value[2] = tmp;
for (int p = 0; p < long_value.length; p++) {
if (p == 2) {
value += " | Native:" + String.valueOf(long_value[p] + "KB");
} else if (p == 1) {
value += " | Dalvik:" + String.valueOf(long_value[p] + "KB");
} else if (p == 0) {
value += "Total:" + String.valueOf(long_value[p] + "KB");
}
}
OpPerfBridge.addHistory(op, value, long_value);
return value;
} else if (op.getKey().equals(CommonString.pm_pd_key + i + ":" + AUTManager.pNames[i])) {
long[] long_value1 = MemUtils.getPrivDirty(GTApp.getContext(), Integer.parseInt(AUTManager.pIds[i]));
long tmp = long_value1[0];
long_value1[0] = long_value1[2];
long_value1[2] = tmp;
for (int pos = 0; pos < long_value1.length; pos++) {
if (pos == 2) {
value += " | Native:" + String.valueOf(long_value1[pos]);
} else if (pos == 1) {
value += " | Dalvik:" + String.valueOf(long_value1[pos]);
} else if (pos == 0) {
value += "Total:" + String.valueOf(long_value1[pos]);
}
}
OpPerfBridge.addHistory(op, value, long_value1);
return value;
} else if (op.getKey().equals(CommonString.pm_hp_key + i + ":" + AUTManager.pNames[i])) {
long[] longhp_value = MemUtils.getHeapDalvik();
long[] longhp_value2 = MemUtils.getHeapNative();
long[] long_value3 = new long[2];
// .getHeapDalvik();(GTSettingActivity.Pid[i]);
long_value3[0] = longhp_value2[1];
long_value3[1] = longhp_value[1];
value += "Native:" + String.valueOf(longhp_value2[1] + "/" + String.valueOf(longhp_value2[0]));
value += " | Dalvik:" + String.valueOf(longhp_value[1] + "/" + String.valueOf(longhp_value[0]));
OpPerfBridge.addHistory(op, value, long_value3);
return value;
}
}
} catch (Exception e) {
}
return value;
}
use of com.tencent.wstt.gt.OutPara in project GT by Tencent.
the class DaemonHandler method handleMessage.
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case // 发消息提示用户,通知
MEM_TOP_WARNING_FLAG:
GTMainActivity.notification = NotificationHelper.genNotification(GTApp.getContext(), 0, R.drawable.gt_entrlogo, "GT", -1, "GT:Memory Waring", "More than " + GTMemoryDaemonThread.topLevelLimit + " GW and Prof records.", GTMainActivity.class, false, true, NotificationHelper.DEFAULT_VB);
NotificationHelper.notify(GTApp.getContext(), 31, GTMainActivity.notification);
break;
case // 发消息提示用户,通知
MEM_SECOND_WARNING_FLAG:
GTMainActivity.notification = NotificationHelper.genNotification(GTApp.getContext(), 0, R.drawable.gt_entrlogo, "GT", -1, "GT:Memory Waring", "More than " + GTMemoryDaemonThread.secondLevelLimit + " GW and Prof records.", GTMainActivity.class, false, true, NotificationHelper.DEFAULT_VB);
NotificationHelper.notify(GTApp.getContext(), 32, GTMainActivity.notification);
break;
case MEM_THIRD_WARNING_FLAG:
GTMainActivity.notification = NotificationHelper.genNotification(GTApp.getContext(), 0, R.drawable.gt_entrlogo, "GT", -1, "GT:Memory Waring", "More than " + GTMemoryDaemonThread.thirdLevelLimit + " GW and Prof records.", GTMainActivity.class, false, true, NotificationHelper.DEFAULT_VB);
NotificationHelper.notify(GTApp.getContext(), 32, GTMainActivity.notification);
break;
case // 发消息提示用户,通知
MEM_SINGLE_WARNING_FLAG:
OutPara op = (OutPara) (msg.obj);
GTMainActivity.notification = NotificationHelper.genNotification(GTApp.getContext(), 0, R.drawable.gt_entrlogo, "GT", -1, "GT:Memory Waring", "OutPara " + op.getAlias() + " has more than " + GTMemoryDaemonThread.singleLimit + " records.", GTMainActivity.class, false, true, NotificationHelper.DEFAULT_VB);
NotificationHelper.notify(GTApp.getContext(), 33, GTMainActivity.notification);
break;
}
}
use of com.tencent.wstt.gt.OutPara in project GT by Tencent.
the class Client method setOutPara.
/**
* 设置输出参数值,值类型为int型,更新的输出参数值会在控制台和输出界面中展示。
*
* @param ParaName
* 输出参数的名称
* @param value
* 输出参数的值
* @param inlog
* 本次设置操作是否打印到日志中记录
*/
public void setOutPara(String paraName, int value) {
OutPara outPara = getOutPara(paraName);
if (null != outPara && OutPara.DISPLAY_DISABLE != outPara.getDisplayProperty()) {
outPara.setValue(String.valueOf(value));
// add on 20130923 为了出参支持历史曲线
OpPerfBridge.addHistory(outPara, outPara.getValue(), value);
}
}
Aggregations