Search in sources :

Example 21 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class GTOpSMActivity method createRealtimeData.

/*
	 * 用实时数据更新图表数据
	 */
private void createRealtimeData() {
    TagTimeEntry anchorEntry = dataSet;
    if (dataSet.getSubTagEntrys().length > 0) {
        anchorEntry = dataSet.getSubTagEntrys()[0];
    }
    if (anchorEntry.getRecordSize() == lastdataSetLength) {
        return;
    }
    lastdataSetLength = anchorEntry.getRecordSize();
    int start = lastdataSetLength > GTPerfDetailView.xMax ? lastdataSetLength - GTPerfDetailView.xMax : 0;
    chartView.setInput(start);
    chartView.postInvalidate();
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry)

Example 22 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class LogUtils method writeGWDataForSM.

public static void writeGWDataForSM(final GWSaveEntry saveEntry, TagTimeEntry tte) {
    if (!GTUtils.isSDCardExist() || tte == null) {
        return;
    }
    if (!tte.hasChild() && tte.getRecordSize() == 0) {
        return;
    } else if (tte.hasChild() && tte.getSubTagEntrys()[0].getRecordSize() == 0) {
        return;
    }
    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();
    // SM的保存文件名使用出参名,这样多个Client同时保存不会出现重名覆盖问题
    String fName = getTagTimeEntryFileName(tte, saveEntry);
    File f = new File(folder, fName);
    if (f.exists()) {
        return;
    }
    FileWriter fw = null;
    // 在这里最后算一下分,否则没进具体页没有算分的机会
    List<Integer> smrs = SMUtils.getSmDetail(tte.getRecordList());
    tte.exInt_1 = smrs.get(1);
    tte.exInt_2 = smrs.get(3);
    tte.exInt_3 = smrs.get(5);
    try {
        fw = new FileWriter(f, true);
        StringBuffer sb = new StringBuffer();
        sb.append("key,");
        sb.append(tte.getName());
        sb.append("\r\n");
        sb.append("alias,");
        sb.append(tte.getAlias());
        sb.append("\r\n");
        sb.append("unit,");
        // PSS和PD的单位特殊,保存的KB,曲线图上显示的MB
        sb.append(tte.getUnit());
        sb.append("\r\n");
        int size = tte.getRecordSize();
        long firstTime = tte.getRecord(0).time;
        long lastTime = tte.getRecord(size - 1).time;
        ArrayList<TimeEntry> tempRecordList = tte.getRecordList();
        sb.append("begin date,");
        sb.append(GTUtils.getDate(firstTime));
        sb.append("\r\n");
        sb.append("end date,");
        sb.append(GTUtils.getDate(lastTime));
        sb.append("\r\n");
        sb.append("count,");
        sb.append(size);
        sb.append("\r\n");
        sb.append("\r\n");
        sb.append("bad time,");
        sb.append(tte.exInt_1);
        sb.append("\r\n");
        sb.append("good time,");
        sb.append(tte.exInt_2);
        sb.append("\r\n");
        sb.append("score,");
        sb.append(tte.exInt_3);
        sb.append("\r\n");
        sb.append("min,");
        sb.append(tte.getMin());
        sb.append("\r\n");
        sb.append("avg,");
        sb.append(tte.getAve());
        sb.append("\r\n");
        sb.append("\r\n");
        for (TimeEntry time : tempRecordList) {
            if (sb.length() > 8192) {
                writeNotClose(sb.toString(), f, fw);
                sb = new StringBuffer();
            }
            sb.append(time);
            sb.append("\r\n");
        }
        if (tte.getRecordSize() != 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        sb.append("\r\n");
        writeNotClose(sb.toString(), f, fw);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        FileUtil.closeWriter(fw);
    }
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) GroupTimeEntry(com.tencent.wstt.gt.ui.model.GroupTimeEntry) TimeEntry(com.tencent.wstt.gt.ui.model.TimeEntry) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File)

Example 23 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class LogUtils method writeGWData.

public static void writeGWData(final GWSaveEntry saveEntry, TagTimeEntry tte) {
    if (!GTUtils.isSDCardExist() || tte == null) {
        return;
    }
    if (!tte.hasChild() && tte.getRecordSize() == 0) {
        return;
    } else if (tte.hasChild() && tte.getSubTagEntrys()[0].getRecordSize() == 0) {
        return;
    }
    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 = getTagTimeEntryFileName(tte, saveEntry);
    File f = new File(folder, fName);
    if (f.exists()) {
        return;
    }
    FileWriter fw = null;
    try {
        fw = new FileWriter(f, true);
        StringBuffer sb = new StringBuffer();
        sb.append("key,");
        sb.append(tte.getName());
        sb.append("\r\n");
        sb.append("alias,");
        sb.append(tte.getAlias());
        sb.append("\r\n");
        sb.append("unit,");
        // PSS和PD的单位特殊,保存的KB,曲线图上显示的MB
        if (tte.getFunctionId() == Functions.PERF_DIGITAL_MULT_MEM) {
            sb.append("(KB)");
        } else {
            sb.append(tte.getUnit());
        }
        sb.append("\r\n");
        if (!tte.hasChild()) {
            int size = tte.getRecordSize();
            long firstTime = tte.getRecord(0).time;
            long lastTime = tte.getRecord(size - 1).time;
            ArrayList<TimeEntry> tempRecordList = tte.getRecordList();
            sb.append("begin date,");
            sb.append(GTUtils.getDate(firstTime));
            sb.append("\r\n");
            sb.append("end date,");
            sb.append(GTUtils.getDate(lastTime));
            sb.append("\r\n");
            sb.append("count,");
            sb.append(size);
            sb.append("\r\n");
            sb.append("\r\n");
            sb.append("min,");
            sb.append(tte.getMin());
            sb.append("\r\n");
            sb.append("max,");
            sb.append(tte.getMax());
            sb.append("\r\n");
            sb.append("avg,");
            sb.append(tte.getAve());
            sb.append("\r\n");
            sb.append("\r\n");
            for (TimeEntry time : tempRecordList) {
                if (sb.length() > 8192) {
                    writeNotClose(sb.toString(), f, fw);
                    sb = new StringBuffer();
                }
                sb.append(time);
                sb.append("\r\n");
            }
        } else // 支持多组数据的保存
        {
            TagTimeEntry temp = tte.getChildren()[0];
            int size = temp.getRecordSize();
            long firstTime = temp.getRecord(0).time;
            long lastTime = temp.getRecord(size - 1).time;
            sb.append("begin date,");
            sb.append(GTUtils.getDate(firstTime));
            sb.append("\r\n");
            sb.append("end date,");
            sb.append(GTUtils.getDate(lastTime));
            sb.append("\r\n");
            sb.append("count,");
            sb.append(size);
            sb.append("\r\n");
            sb.append("\r\n");
            sb.append(",");
            for (TagTimeEntry child : tte.getChildren()) {
                sb.append(child.getName());
                sb.append(",");
            }
            sb.deleteCharAt(sb.length() - 1);
            sb.append("\r\n");
            sb.append("min,");
            for (TagTimeEntry child : tte.getChildren()) {
                sb.append(child.getMin());
                sb.append(",");
            }
            sb.deleteCharAt(sb.length() - 1);
            sb.append("\r\n");
            sb.append("max,");
            for (TagTimeEntry child : tte.getChildren()) {
                sb.append(child.getMax());
                sb.append(",");
            }
            sb.deleteCharAt(sb.length() - 1);
            sb.append("\r\n");
            sb.append("avg,");
            for (TagTimeEntry child : tte.getChildren()) {
                sb.append(child.getAve());
                sb.append(",");
            }
            sb.deleteCharAt(sb.length() - 1);
            sb.append("\r\n");
            sb.append("\r\n");
            for (int i = 0; i < size; 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);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        FileUtil.closeWriter(fw);
    }
    // 简单过滤保存
    if (GTMemHelperFloatview.memInfoList.size() <= 0) {
        // 不存在这种数据直接return
        return;
    }
    File tagFile = new File(folder, "tagMem_" + saveEntry.now + LogUtils.GW_POSFIX);
    if (tagFile.exists()) {
        tagFile.delete();
    }
    FileWriter fwTagFile = null;
    try {
        fwTagFile = new FileWriter(tagFile, true);
    } catch (IOException e) {
        e.printStackTrace();
    }
    StringBuffer sb = null;
    sb = new StringBuffer();
    sb.append("time(ms)");
    sb.append(",");
    sb.append("DalvikHeapSize(KB)");
    sb.append(",");
    sb.append("DalvikAllocated(KB)");
    sb.append(",");
    sb.append("private_dirty(KB)");
    sb.append(",");
    sb.append("PSS_Total(KB)");
    sb.append(",");
    sb.append("PSS_Dalvik(KB)");
    sb.append(",");
    sb.append("PSS_Native(KB)");
    sb.append(",");
    sb.append("PSS_OtherDev(KB)");
    sb.append(",");
    sb.append("PSS_Graphics(KB)");
    sb.append(",");
    sb.append("PSS_GL(KB)");
    sb.append(",");
    sb.append("PSS_Unknow(KB)");
    sb.append("\r\n");
    for (MemInfo mem : GTMemHelperFloatview.memInfoList) {
        if (sb.length() > 8192) {
            writeNotClose(sb.toString(), tagFile, fwTagFile);
            sb = new StringBuffer();
        }
        sb.append(GTUtils.getSaveTime(mem.time));
        sb.append(",");
        sb.append(mem.dalvikHeapSize);
        sb.append(",");
        sb.append(mem.dalvikAllocated);
        sb.append(",");
        sb.append(mem.private_dirty);
        sb.append(",");
        sb.append(mem.pss_total);
        sb.append(",");
        sb.append(mem.pss_Dalvik);
        sb.append(",");
        sb.append(mem.pss_Native);
        sb.append(",");
        sb.append(mem.pss_OtherDev);
        sb.append(",");
        sb.append(mem.pss_graphics);
        sb.append(",");
        sb.append(mem.pss_gl);
        sb.append(",");
        sb.append(mem.pss_UnKnown);
        sb.append("\r\n");
    }
    writeNotClose(sb.toString(), tagFile, fwTagFile);
    FileUtil.closeWriter(fwTagFile);
// add on 20131225 有手动tag记录内存值的情况,先把tag的内存值保存了 end
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) GroupTimeEntry(com.tencent.wstt.gt.ui.model.GroupTimeEntry) TimeEntry(com.tencent.wstt.gt.ui.model.TimeEntry) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) MemInfo(com.tencent.wstt.gt.proInfo.floatView.MemInfo)

Example 24 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class LogUtils method writeTimeLog.

public static void writeTimeLog(List<GroupTimeEntry> list, 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 = null;
    for (GroupTimeEntry gte : list) {
        for (TagTimeEntry tte : gte.entrys()) {
            sb = new StringBuffer();
            sb.append("group,");
            sb.append(gte.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");
            ArrayList<TimeEntry> tempRecordList = tte.getRecordList();
            for (TimeEntry time : tempRecordList) {
                if (sb.length() > 8192) {
                    writeNotClose(sb.toString(), f, fw);
                    sb = new StringBuffer();
                }
                sb.append(time);
                // sb.append(",");
                sb.append("\r\n");
            }
            if (!tempRecordList.isEmpty()) {
                sb.deleteCharAt(sb.length() - 1);
            }
            // 可以及时释放
            tempRecordList = null;
            sb.append("\r\n");
            writeNotClose(sb.toString(), f, fw);
        }
    }
    FileUtil.closeWriter(fw);
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) GroupTimeEntry(com.tencent.wstt.gt.ui.model.GroupTimeEntry) TimeEntry(com.tencent.wstt.gt.ui.model.TimeEntry) FileWriter(java.io.FileWriter) IOException(java.io.IOException) GroupTimeEntry(com.tencent.wstt.gt.ui.model.GroupTimeEntry) File(java.io.File)

Example 25 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class GTGWInternal method saveAllGWData.

public static void saveAllGWData(GWSaveEntry saveEntry) {
    setLastSaveFolder(saveEntry.path3);
    String now = GTUtils.getSaveDate();
    saveEntry.setNow(now);
    TagTimeEntry[] ttes = OpPerfBridge.getAllProfilerData();
    for (TagTimeEntry tte : ttes) {
        if (null != tte && tte.getAlias().equals("SM")) {
            LogUtils.writeGWDataForSM(saveEntry, tte);
        } else {
            LogUtils.writeGWData(saveEntry, tte);
        }
    }
    LogUtils.writeGWDesc(saveEntry, ttes);
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry)

Aggregations

TagTimeEntry (com.tencent.wstt.gt.ui.model.TagTimeEntry)35 GroupTimeEntry (com.tencent.wstt.gt.ui.model.GroupTimeEntry)11 TimeEntry (com.tencent.wstt.gt.ui.model.TimeEntry)5 File (java.io.File)5 FileWriter (java.io.FileWriter)5 IOException (java.io.IOException)5 Builder (android.app.AlertDialog.Builder)4 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 View (android.view.View)4 TextView (android.widget.TextView)4 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 OnClickListener (android.view.View.OnClickListener)3 ImageButton (android.widget.ImageButton)3 ImageView (android.widget.ImageView)3 LinearLayout (android.widget.LinearLayout)3 RelativeLayout (android.widget.RelativeLayout)3 OutPara (com.tencent.wstt.gt.OutPara)3 GWSaveEntry (com.tencent.wstt.gt.log.GWSaveEntry)3