use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.
the class LogUtils method writeTimeDetail.
public static void writeTimeDetail(TagTimeEntry tte, String fileName) {
if (!GTUtils.isSDCardExist()) {
return;
}
int la = fileName.lastIndexOf(".");
if (la < 0) {
fileName = fileName + LogUtils.TLOG_POSFIX;
} else {
String temp = fileName.substring(la);
if (temp.contains(FileUtil.separator) || temp.contains("\\")) {
// "."是目录名的一部分而不是后缀名的情况
fileName = fileName + LogUtils.TLOG_POSFIX;
}
// else fileName = fileName
}
File f = null;
if (fileName.contains(FileUtil.separator) || fileName.contains("\\")) {
f = new File(fileName);
} else {
Env.ROOT_TIME_FOLDER.mkdirs();
f = new File(Env.ROOT_TIME_FOLDER, fileName);
}
if (f.exists()) {
f.delete();
}
FileWriter fw = null;
try {
fw = new FileWriter(f, true);
} catch (IOException e) {
e.printStackTrace();
}
StringBuffer sb = new StringBuffer();
if (null != tte.getParent() && tte.getParent() instanceof GroupTimeEntry) {
sb.append("group,");
sb.append(tte.getParent().getName());
sb.append("\r\n");
}
sb.append("tag,");
sb.append(tte.getName());
sb.append("\r\n");
sb.append("isInThread,");
sb.append(tte.getTid() == 0 ? "false" : "true");
sb.append("\r\n");
if (!tte.hasChild()) {
for (TimeEntry time : tte.getRecordList()) {
if (sb.length() > 8192) {
writeNotClose(sb.toString(), f, fw);
sb = new StringBuffer();
}
sb.append(time);
sb.append("\r\n");
}
} else // 支持多组数据的保存
{
for (int i = 0; i < tte.getSubTagEntrys()[0].getRecordSize(); i++) {
for (int j = 0; j < tte.getSubTagEntrys().length; j++) {
TagTimeEntry subEntry = tte.getSubTagEntrys()[j];
TimeEntry time = subEntry.getRecord(i);
if (sb.length() > 8192) {
writeNotClose(sb.toString(), f, fw);
sb = new StringBuffer();
}
if (j == 0) {
sb.append(time);
} else {
sb.append(time.reduce);
}
if (j == tte.getSubTagEntrys().length - 1) {
sb.append("\r\n");
} else {
sb.append(",");
}
}
}
}
if (tte.getRecordSize() != 0) {
sb.deleteCharAt(sb.length() - 1);
}
sb.append("\r\n");
writeNotClose(sb.toString(), f, fw);
FileUtil.closeWriter(fw);
}
use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.
the class LogUtils method writeGWDesc.
public static void writeGWDesc(final GWSaveEntry saveEntry, final TagTimeEntry... ttes) {
String sFolder = Env.S_ROOT_GW_FOLDER + saveEntry.path1 + FileUtil.separator + saveEntry.path2 + FileUtil.separator + saveEntry.path3 + FileUtil.separator;
File folder = new File(sFolder);
folder.mkdirs();
String fName = GW_DESC_PREFIX + saveEntry.now + GW_DESC_POSFIX;
File f = new File(folder, fName);
FileWriter fw = null;
try {
StringBuffer sb = new StringBuffer();
sb.append("gtdesc:=");
sb.append(saveEntry.desc);
sb.append("\r\n");
sb.append("\r\n");
sb.append("opfiles:=");
sb.append("\r\n");
// 本次测试提交的文件
boolean hasValidData = false;
for (TagTimeEntry tte : ttes) {
String tteFileName = getTagTimeEntryFileName(tte, saveEntry);
if (!tte.hasChild() && tte.getRecordSize() > 0 || tte.hasChild() && tte.getSubTagEntrys()[0].getRecordSize() > 0) {
hasValidData = true;
sb.append(tteFileName);
sb.append("\r\n");
}
}
if (hasValidData) {
fw = new FileWriter(f, true);
writeNotClose(sb.toString(), f, fw);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
FileUtil.closeWriter(fw);
}
}
use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.
the class GTGWInternal method clearAllGWData.
public static void clearAllGWData() {
TagTimeEntry[] ttes = OpPerfBridge.getAllProfilerData();
for (TagTimeEntry tte : ttes) {
tte.clear();
// 如果是流量数据,还要同时reset
String key = tte.getName();
NetUtils.clearNetValue(key);
}
}
use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.
the class GTGWInternal method clearAllEnableGWData.
public static void clearAllEnableGWData() {
TagTimeEntry[] ttes = OpPerfBridge.getAllEnableProfilerData();
for (TagTimeEntry tte : ttes) {
tte.clear();
// 如果是流量数据,还要同时reset
String key = tte.getName();
NetUtils.clearNetValue(key);
}
}
use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.
the class GTTimeInternal method getEntrys.
public static NamedEntry[] getEntrys() {
List<GroupTimeEntry> root = timeLogController.getShowList();
List<NamedEntry> result = new ArrayList<NamedEntry>();
for (GroupTimeEntry gte : root) {
List<TagTimeEntry> tagEntryList = gte.entrys();
if (tagEntryList.size() > 0) {
result.add(gte);
for (TagTimeEntry tte : tagEntryList) {
result.add(tte);
}
}
}
return result.toArray(EMPTY_NAMED_ENTRY);
}
Aggregations