Search in sources :

Example 6 with TagTimeEntry

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);
}
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 7 with TagTimeEntry

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);
    }
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File)

Example 8 with TagTimeEntry

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);
    }
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry)

Example 9 with TagTimeEntry

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);
    }
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry)

Example 10 with TagTimeEntry

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);
}
Also used : NamedEntry(com.tencent.wstt.gt.ui.model.NamedEntry) TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) ArrayList(java.util.ArrayList) GroupTimeEntry(com.tencent.wstt.gt.ui.model.GroupTimeEntry)

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