use of com.tencent.wstt.gt.ui.model.GroupTimeEntry in project GT by Tencent.
the class GTMemoryDaemonThread method doTask.
@Override
void doTask() {
int total = 0;
TagTimeEntry[] opPerfDatas = OpPerfBridge.getAllProfilerData();
for (TagTimeEntry tte : opPerfDatas) {
int single = 0;
if (tte.hasChild()) {
single = tte.getChildren()[0].getRecordSize();
// 总值计算时,复数要乘倍数
total += single * tte.getChildren().length;
} else {
single = tte.getRecordSize();
total += single;
}
validSingleLimit(single, tte);
}
if (// gw部分已经超一级警戒了,prof部分就不需要看了
!validTopLimit(total)) {
return;
}
if (GTTime.isEnable()) {
List<GroupTimeEntry> timeGroupList = GTTimeInternal.getAllGroup();
for (GroupTimeEntry gte : timeGroupList) {
for (TagTimeEntry tte : gte.entrys()) {
int single = tte.getRecordSize();
total += single;
}
}
}
if (// 先判断一级警戒,如果没有过一级警戒,才会判断二级警戒
!validTopLimit(total)) {
return;
}
if (// 先判断二级警戒,如果没有过二级警戒,才会判断三级警戒
!validSecendLimit(total)) {
return;
}
validThirdLimit(total);
}
use of com.tencent.wstt.gt.ui.model.GroupTimeEntry 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);
}
use of com.tencent.wstt.gt.ui.model.GroupTimeEntry 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.GroupTimeEntry in project GT by Tencent.
the class GTMemoryDaemonHelper method startGWOrProfValid.
public static boolean startGWOrProfValid() {
/*
* 判断GW和Prof的总数是否超上限,超上限则不允许checked,提示用户
*/
int total = 0;
TagTimeEntry[] opPerfDatas = OpPerfBridge.getAllProfilerData();
for (TagTimeEntry tte : opPerfDatas) {
int single = 0;
if (tte.hasChild()) {
single = tte.getChildren()[0].getRecordSize();
// 总值计算时,复数要乘倍数
total += single * tte.getChildren().length;
} else {
single = tte.getRecordSize();
total += single;
}
}
if (GTTime.isEnable()) {
List<GroupTimeEntry> timeGroupList = GTTimeInternal.getAllGroup();
for (GroupTimeEntry gte : timeGroupList) {
for (TagTimeEntry tte : gte.entrys()) {
int single = tte.getRecordSize();
total += single;
}
}
}
if (total >= GTMemoryDaemonThread.topLevelLimit) {
ToastUtil.ShowLongToast(GTApp.getContext(), "More than " + GTMemoryDaemonThread.topLevelLimit + " GW or Prof records." + "You should save and clear records first.");
return false;
}
return true;
}
use of com.tencent.wstt.gt.ui.model.GroupTimeEntry in project GT by Tencent.
the class LogTimeController method recordDigital.
/**
* 记录单点的性能数据(start和end这种成对的称为双点性能数据),也按tid区分全局的还是线程的
*/
public void recordDigital(long tid, String group, String tag, long[] datas, int funcId) {
if (!started) {
return;
}
if (null != group && null != tag) {
GroupTimeEntry groupEntry = groupMap.get(group);
if (null == groupEntry) {
groupEntry = new GroupTimeEntry(group);
lock.lock();
groupMap.put(group, groupEntry);
lock.unlock();
}
// 从Group中取出由tag, tid共同标示的统计对象(exKey无用)
TagTimeEntry staticsTagTimeEntry = groupEntry.getStaticsEntry(tag, tid);
if (null == staticsTagTimeEntry) {
staticsTagTimeEntry = new TagTimeEntry(groupEntry);
staticsTagTimeEntry.setName(tag);
staticsTagTimeEntry.setTid(tid);
staticsTagTimeEntry.setFunctionId(funcId);
staticsTagTimeEntry.initChildren(datas.length - 1);
groupEntry.addStaticsEntry(staticsTagTimeEntry);
}
if (Functions.PERF_DIGITAL_MULT == funcId || Functions.PERF_DIGITAL_MULT_MEM == funcId) {
TagTimeEntry[] subEntrys = staticsTagTimeEntry.getSubTagEntrys();
for (int i = 0; i < subEntrys.length; i++) {
TagTimeEntry subEntry = subEntrys[i];
subEntry.add(datas[i]);
}
// TODO 得记录一个维度的值,否则外面UI无法展示
staticsTagTimeEntry.add(datas[0]);
} else {
staticsTagTimeEntry.add(datas[0]);
}
}
}
Aggregations