Search in sources :

Example 1 with MemoryView

use of com.tencent.wstt.apt.ui.views.MemoryView in project GT by Tencent.

the class GetCurCheckedStateUtil method update.

/**
	* @Description 按照设置和设备视图中的更改更新CPU和内存视图中的曲线 
	* @param    
	* @return void 
	* @throws
	 */
public static void update() {
    SettingView settingViewPart = (SettingView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(SettingView.ID);
    DevicesView deviceViewPart = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
    CPUView cpuViewPart = (CPUView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CPUView.ID);
    MemoryView memViewPart = (MemoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MemoryView.ID);
    if (deviceViewPart == null || settingViewPart == null) {
        return;
    }
    boolean[] pkgCheckeds = deviceViewPart.getPkgChecked();
    if (cpuViewPart != null) {
        for (int i = 0; i < pkgCheckeds.length; i++) {
            cpuViewPart.cpuRealTimeChart.setTimeSeriesEnable(i, 0, pkgCheckeds[i]);
        }
        //当启动APT后,直接打开log,此时tableviewfilter为空
        if (cpuViewPart.cpuTableFilter != null) {
            ((TableViewFilter) cpuViewPart.cpuTableFilter).update(pkgCheckeds, new boolean[] { true });
            cpuViewPart.cpuViewer.refresh();
        }
        if (TestSence.getInstance().isTestJiffies) {
            if (cpuViewPart.jiffiesTableFilter != null) {
                ((TableViewFilter) cpuViewPart.jiffiesTableFilter).update(pkgCheckeds, new boolean[] { true });
                cpuViewPart.jiffiesViewer.refresh();
            }
        }
    }
    if (memViewPart != null) {
        boolean[] memStateCheckeds = settingViewPart.getMemChecked();
        //更新曲线
        for (int i = 0; i < pkgCheckeds.length; i++) {
            for (int j = 0; j < memStateCheckeds.length; j++) {
                memViewPart.memRealTimeChart.setTimeSeriesEnable(i, j, pkgCheckeds[i] && memStateCheckeds[j]);
            }
        }
        //更新统计表格
        if (memViewPart.tableFilter != null) {
            ((TableViewFilter) memViewPart.tableFilter).update(pkgCheckeds, memStateCheckeds);
            memViewPart.viewer.refresh();
        }
    }
}
Also used : MemoryView(com.tencent.wstt.apt.ui.views.MemoryView) SettingView(com.tencent.wstt.apt.ui.views.SettingView) CPUView(com.tencent.wstt.apt.ui.views.CPUView) DevicesView(com.tencent.wstt.apt.ui.views.DevicesView)

Example 2 with MemoryView

use of com.tencent.wstt.apt.ui.views.MemoryView in project GT by Tencent.

the class TestTaskManager method initTest.

/**
	* @Title: initTest  
	* @Description: 根据测试场景配置来初始化测试   
	* void 
	* @throws
	 */
public boolean initTest() {
    clear();
    //获取进程列表
    int pkgNumber = TestSence.getInstance().pkgInfos.size();
    String[] pkgNames = new String[pkgNumber];
    String[] pkgAbbreviation = new String[pkgNumber];
    //取进程名的后缀
    for (int i = 0; i < pkgNumber; i++) {
        pkgNames[i] = TestSence.getInstance().pkgInfos.get(i).contents[PkgInfo.NAME_INDEX];
        int index = pkgNames[i].lastIndexOf(".");
        ;
        pkgAbbreviation[i] = pkgNames[i].substring(index + 1, pkgNames[i].length());
    }
    CPUView cpuViewPart = (CPUView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CPUView.ID);
    MemoryView memViewPart = (MemoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MemoryView.ID);
    //设置当前测试场景的结果保存目录
    Date curDate = new Date(System.currentTimeMillis());
    TestSence.getInstance().curDir = Constant.SIMPLE_DATE_FORMAT_SECOND.format(curDate);
    APTConsoleFactory.getInstance().APTPrint("测试开始时间:" + TestSence.getInstance().curDir);
    if (TestSence.getInstance().itemTestSwitch[Constant.CPU_INDEX]) {
        if (cpuViewPart == null) {
            return false;
        }
        //打开文件
        if (!(WriteFileUtil.getInstance().openWriteFile(TestSence.getInstance().curDir, Constant.TEXT_ITEM_TITLES[Constant.CPU_INDEX], TestSence.bufThreshold[0]))) {
            APTConsoleFactory.getInstance().APTPrint("创建CPU结果文件失败");
            return false;
        }
        //写文件头
        if (!APTLogFileParse.writeAPTLogFileHeader(Constant.CPU_INDEX)) {
            APTConsoleFactory.getInstance().APTPrint("写CPU文件头部失败");
            return false;
        }
        cpuViewPart.cpuRealTimeChart.initDataset(pkgAbbreviation, new String[] { Constant.CPU_ITEM_TITLES[Constant.CPU_PERSENT_INDEX] });
        DataProvider dataProvider = new CPUProvider(pkgNames, DeviceInfo.getInstance().androidVersion, TestSence.getInstance().cpuTestMethod);
        dataProvider.attach(new ChartObserver(cpuViewPart.cpuRealTimeChart));
        dataProvider.attach(new TableAllDataObserver(cpuViewPart.cpuViewer, pkgAbbreviation, new String[] { Constant.CPU_ITEM_TITLES[Constant.CPU_PERSENT_INDEX] }));
        dataProvider.attach(new FileObserver(Constant.TEXT_ITEM_TITLES[Constant.CPU_INDEX]));
        TestTask tt = new TestTask(dataProvider, TestSence.getInstance().itemTestPeriod[Constant.CPU_INDEX]);
        addTestTask(tt);
        cpuViewPart.setCpuTableViewerFilter(new TableViewFilter(pkgAbbreviation, new String[] { Constant.CPU_ITEM_TITLES[Constant.CPU_PERSENT_INDEX] }));
        if (TestSence.getInstance().isTestJiffies) {
            DevicesView dv = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
            if (dv == null) {
                return false;
            }
            List<PkgInfo> pkgInfos = TestSence.getInstance().pkgInfos;
            String[] pids = new String[pkgInfos.size()];
            for (int i = 0; i < pids.length; i++) {
                pids[i] = pkgInfos.get(i).contents[PkgInfo.PID_INDEX];
            }
            DataProvider jiffiesDataProvider = new JiffiesProviderNew(pkgNumber);
            cpuViewPart.setJiffiesTableViewerFilter(new TableViewFilter(pkgAbbreviation, new String[] { Constant.CPU_ITEM_TITLES[Constant.CPU_JIFFIES_INDEX] }));
            //jiffiesDataProvider.attach(new TableAllDataObserver(cpuViewPart.jiffiesViewer, pkgAbbreviation, new String[]{Constant.CPU_ITEM_TITLES[Constant.CPU_JIFFIES_INDEX]}));
            jiffiesDataProvider.attach(new JiffiesTableObserver(cpuViewPart.jiffiesViewer, pkgAbbreviation));
            jiffiesDataProvider.attach(new PidUpdateObserver(dv.targetPkgTableViewer, pids));
            TestTask jiffiesTT = new TestTask(jiffiesDataProvider, TestSence.getInstance().itemTestPeriod[Constant.CPU_INDEX]);
            addTestTask(jiffiesTT);
        }
        APTConsoleFactory.getInstance().APTPrint("CPU测试Ready");
    }
    //内存测试
    if (TestSence.getInstance().itemTestSwitch[Constant.MEM_INDEX]) {
        if (memViewPart == null) {
            return false;
        }
        //打开文件
        if (!(WriteFileUtil.getInstance().openWriteFile(TestSence.getInstance().curDir, Constant.TEXT_ITEM_TITLES[Constant.MEM_INDEX], TestSence.bufThreshold[1]))) {
            APTConsoleFactory.getInstance().APTPrint("创建内存结果文件失败");
            return false;
        }
        //写文件头
        if (!APTLogFileParse.writeAPTLogFileHeader(Constant.MEM_INDEX)) {
            APTConsoleFactory.getInstance().APTPrint("写内存文件头部失败");
            return false;
        }
        //填充数据
        memViewPart.memRealTimeChart.initDataset(pkgAbbreviation, Constant.MEM_ITEM_TITLES);
        memViewPart.setTableViewerFilter(new TableViewFilter(pkgAbbreviation, Constant.MEM_ITEM_TITLES));
        //初始化内存视图的数据提供者
        DataProvider dataProvider = new MemProvider(pkgNames, DeviceInfo.getInstance().androidVersion);
        //主持内存数据的观察者
        dataProvider.attach(new ChartObserver(memViewPart.memRealTimeChart));
        dataProvider.attach(new TableAllDataObserver(memViewPart.viewer, pkgAbbreviation, Constant.MEM_ITEM_TITLES));
        dataProvider.attach(new FileObserver(Constant.TEXT_ITEM_TITLES[Constant.MEM_INDEX]));
        if (TestSence.getInstance().isDumpHprof) {
            dataProvider.attach(new HprofDumpObserver(pkgNames));
        }
        //构建测试任务
        TestTask tt = new TestTask(dataProvider, TestSence.getInstance().itemTestPeriod[Constant.MEM_INDEX]);
        addTestTask(tt);
        memViewPart.setTableViewerFilter(new TableViewFilter(pkgAbbreviation, Constant.MEM_ITEM_TITLES));
        APTConsoleFactory.getInstance().APTPrint("内存测试Ready");
    }
    APTConsoleFactory.getInstance().APTPrint("开始测试更新");
    GetCurCheckedStateUtil.update();
    return true;
}
Also used : PidUpdateObserver(com.tencent.wstt.apt.chart.PidUpdateObserver) MemoryView(com.tencent.wstt.apt.ui.views.MemoryView) ChartObserver(com.tencent.wstt.apt.chart.ChartObserver) MemProvider(com.tencent.wstt.apt.chart.MemProvider) JiffiesProviderNew(com.tencent.wstt.apt.chart.JiffiesProviderNew) TableAllDataObserver(com.tencent.wstt.apt.chart.TableAllDataObserver) Date(java.util.Date) FileObserver(com.tencent.wstt.apt.chart.FileObserver) TableViewFilter(com.tencent.wstt.apt.util.TableViewFilter) DataProvider(com.tencent.wstt.apt.chart.DataProvider) HprofDumpObserver(com.tencent.wstt.apt.chart.HprofDumpObserver) CPUView(com.tencent.wstt.apt.ui.views.CPUView) JiffiesTableObserver(com.tencent.wstt.apt.chart.JiffiesTableObserver) CPUProvider(com.tencent.wstt.apt.chart.CPUProvider) DevicesView(com.tencent.wstt.apt.ui.views.DevicesView)

Example 3 with MemoryView

use of com.tencent.wstt.apt.ui.views.MemoryView in project GT by Tencent.

the class TestTaskManager method stop.

/**
	 * 停止测试
	* @Title: stop  
	* @Description:    
	* void 
	* @throws
	 */
public void stop() {
    for (int i = 0; i < timerPool.size(); i++) {
        timerPool.get(i).cancel();
    }
    clear();
    if (!WriteFileUtil.getInstance().closeAll()) {
        APTConsoleFactory.getInstance().APTPrint("保存文件失败");
    //return;
    }
    CPUView cpuViewPart = (CPUView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CPUView.ID);
    MemoryView memViewPart = (MemoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MemoryView.ID);
    if (cpuViewPart == null || memViewPart == null) {
        return;
    }
    if (TestSence.getInstance().itemTestSwitch[Constant.CPU_INDEX]) {
        String path = Constant.LOG_FOLDER_ON_PC + File.separator + TestSence.getInstance().curDir + File.separator + "APT_CPU.png";
        if (!cpuViewPart.cpuRealTimeChart.saveToPNG(path)) {
            APTConsoleFactory.getInstance().APTPrint("图片保存失败");
        }
    }
    if (TestSence.getInstance().itemTestSwitch[Constant.MEM_INDEX]) {
        String path = Constant.LOG_FOLDER_ON_PC + File.separator + TestSence.getInstance().curDir + File.separator + "APT_Mem.png";
        if (!memViewPart.memRealTimeChart.saveToPNG(path)) {
            APTConsoleFactory.getInstance().APTPrint("图片保存失败");
        }
    }
}
Also used : MemoryView(com.tencent.wstt.apt.ui.views.MemoryView) CPUView(com.tencent.wstt.apt.ui.views.CPUView)

Example 4 with MemoryView

use of com.tencent.wstt.apt.ui.views.MemoryView in project GT by Tencent.

the class APTState method clearChartAndTableData.

/**
	 * 清除曲线和统计表格数据
	* @Title: clearChartAndTableData  
	* @Description:    
	* void 
	* @throws
	 */
private boolean clearChartAndTableData() {
    //APTConsoleFactory.getInstance().APTPrint("clearChartAndTableData:1");
    CPUView cpuViewPart = (CPUView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CPUView.ID);
    //APTConsoleFactory.getInstance().APTPrint("clearChartAndTableData:2");
    MemoryView memViewPart = (MemoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MemoryView.ID);
    if (cpuViewPart != null) {
        if (cpuViewPart.cpuRealTimeChart != null) {
            //APTConsoleFactory.getInstance().APTPrint("clearChartAndTableData:4");
            cpuViewPart.cpuRealTimeChart.clearAllData();
            //APTConsoleFactory.getInstance().APTPrint("clearChartAndTableData:5");
            cpuViewPart.clearStatisticsTableDataForNotUIThread();
        }
    }
    if (memViewPart != null) {
        if (memViewPart.memRealTimeChart != null) {
            memViewPart.memRealTimeChart.clearAllData();
            //APTConsoleFactory.getInstance().APTPrint("clearChartAndTableData:6");
            memViewPart.clearStatisticsTableDataForNotUIThread();
        }
    }
    return true;
}
Also used : MemoryView(com.tencent.wstt.apt.ui.views.MemoryView) CPUView(com.tencent.wstt.apt.ui.views.CPUView)

Aggregations

CPUView (com.tencent.wstt.apt.ui.views.CPUView)4 MemoryView (com.tencent.wstt.apt.ui.views.MemoryView)4 DevicesView (com.tencent.wstt.apt.ui.views.DevicesView)2 CPUProvider (com.tencent.wstt.apt.chart.CPUProvider)1 ChartObserver (com.tencent.wstt.apt.chart.ChartObserver)1 DataProvider (com.tencent.wstt.apt.chart.DataProvider)1 FileObserver (com.tencent.wstt.apt.chart.FileObserver)1 HprofDumpObserver (com.tencent.wstt.apt.chart.HprofDumpObserver)1 JiffiesProviderNew (com.tencent.wstt.apt.chart.JiffiesProviderNew)1 JiffiesTableObserver (com.tencent.wstt.apt.chart.JiffiesTableObserver)1 MemProvider (com.tencent.wstt.apt.chart.MemProvider)1 PidUpdateObserver (com.tencent.wstt.apt.chart.PidUpdateObserver)1 TableAllDataObserver (com.tencent.wstt.apt.chart.TableAllDataObserver)1 SettingView (com.tencent.wstt.apt.ui.views.SettingView)1 TableViewFilter (com.tencent.wstt.apt.util.TableViewFilter)1 Date (java.util.Date)1