public String getColumnString() {
if (DBConstants.VARCHAR.equals(type)) {
- return name + CommonConstants.SPACE + type + "(" + string_size
- + ")" + CommonConstants.SPACE + option;
+ return name + CommonConstants.SPACE + type + "(" + string_size + ")" + CommonConstants.SPACE + option;
} else if (DBConstants.VARCHAR_ARRAY.equals(type)) {
- return type.replaceFirst("\\?", String.valueOf(string_size)) +
- CommonConstants.SPACE + option;
+ return name + CommonConstants.SPACE + "VARCHAR(" + string_size + ") ARRAY"
+ + CommonConstants.SPACE + option;
} else {
- return name + CommonConstants.SPACE + type + CommonConstants.SPACE
- + option;
+ return name + CommonConstants.SPACE + type + CommonConstants.SPACE + option;
}
}
public static final String INTEGER_ARRAY = "INTEGER ARRAY";//$NON-NLS-1$
public static final String BIGINT_ARRAY = "BIGINT ARRAY";//$NON-NLS-1$
public static final String FLOAT_ARRAY = "DOUBLE ARRAY";//$NON-NLS-1$
- public static final String VARCHAR_ARRAY = "VARCHAR(?) ARRAY";
+ public static final String VARCHAR_ARRAY = "VARCHAR ARRAY";
// types constant
public static final String DBTYPE_INT1 = "TINYINT";//$NON-NLS-1$
} else if (rsMetaData.getColumnTypeName(i).contains(
DBConstants.FLOAT_ARRAY)) {
rowData.add(addArray(i, rs, new Float(0)));
+ } else if (rsMetaData.getColumnTypeName(i).contains(
+ DBConstants.VARCHAR_ARRAY)) {
+ rowData.add(addArray(i, rs, new String()));
} else if (rsMetaData.getColumnTypeName(i)
.contains(DBConstants.INTEGER)) {
rowData.add(Integer.valueOf(rs.getInt(i)));
import org.tizen.dynamicanalyzer.database.DBColumn;
import org.tizen.dynamicanalyzer.database.DBConstants;
import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
public class TargetProcessDBTable extends DBTable {
private static final String TABLENAME = "TIMELINE_TARGET_PROCESS";
public static enum COLUMN {
- TIME,
- PID,
+ TIME,
+ PID,
CPU_LOAD,
MEMORY_VIRTUAL,
MEMORY_RESIDENT,
MEMORY_SHARED,
MEMORY_PSS,
- HEAP_ALLOCATION_TOTAL,
- HEAP_ALLOCATION,
+ THREAD_COUNT,
+ HEAP_ALLOCATION_TOTAL_BYTE,
+ HEAP_ALLOCATION_NAME,
+ HEAP_ALLOCATION_BYTE,
+ THREAD_ID,
+ THREAD_LOAD
}
public static final String TIME = "TIME";
public static final String MEMORY_RESIDENT = "MEMORY_RESIDENT";
public static final String MEMORY_SHARED = "MEMORY_SHARED";
public static final String MEMORY_PSS = "MEMORY_PSS";
- public static final String HEAP_ALLOCATION_TOTAL = "HEAP_ALLOCATION_TOTAL";
- public static final String HEAP_ALLOCATION_APP = "HEAP_ALLOCATION_APP";
+ public static final String THREAD_COUNT = "THREAD_COUNT";
+ public static final String HEAP_ALLOCATION_TOTAL_BYTE = "HEAP_ALLOCATION_TOTAL_BYTE";
+ public static final String HEAP_ALLOCATION_NAME = "HEAP_ALLOCATION_NAME";
+ public static final String HEAP_ALLOCATION_BYTE = "HEAP_ALLOCATION_BYTE";
+ public static final String THREAD_ID = "THREAD_ID";
+ public static final String THREAD_LOAD = "THREAD_LOAD";
+ public static final int HEAP_ALLOCATION_NAME_LEN = 256;
@Override
public String getTableName() {
addColumn(new DBColumn(MEMORY_RESIDENT, DBConstants.EMPTY, DBConstants.LONG));
addColumn(new DBColumn(MEMORY_SHARED, DBConstants.EMPTY, DBConstants.LONG));
addColumn(new DBColumn(MEMORY_PSS, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(HEAP_ALLOCATION_TOTAL, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(HEAP_ALLOCATION_APP, DBConstants.EMPTY, DBConstants.LONG));
+ addColumn(new DBColumn(THREAD_COUNT, DBConstants.EMPTY, DBConstants.INTEGER));
+ addColumn(new DBColumn(HEAP_ALLOCATION_TOTAL_BYTE, DBConstants.EMPTY, DBConstants.LONG));
+ addColumn(new DBColumn(HEAP_ALLOCATION_NAME, DBConstants.EMPTY, DBConstants.VARCHAR_ARRAY,
+ HEAP_ALLOCATION_NAME_LEN));
+ addColumn(new DBColumn(HEAP_ALLOCATION_BYTE, DBConstants.EMPTY, DBConstants.BIGINT_ARRAY));
+ addColumn(new DBColumn(THREAD_ID, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
+ addColumn(new DBColumn(THREAD_LOAD, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
}
@Override
isPrepared = false;
} else {
try {
- prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
- prep.setInt(2, (Integer) (rowData.get(COLUMN.PID.ordinal())));
- prep.setFloat(3, (Float) (rowData.get(COLUMN.CPU_LOAD.ordinal())));
- prep.setLong(4, (Long) (rowData.get(COLUMN.MEMORY_VIRTUAL.ordinal())));
- prep.setLong(5, (Long) (rowData.get(COLUMN.MEMORY_RESIDENT.ordinal())));
- prep.setLong(6, (Long) (rowData.get(COLUMN.MEMORY_SHARED.ordinal())));
- prep.setLong(7, (Long) (rowData.get(COLUMN.MEMORY_PSS.ordinal())));
- prep.setLong(8, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION_TOTAL.ordinal())));
- prep.setLong(9, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION.ordinal())));
+ int index = 0;
+ prep.setLong(++index, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+ prep.setInt(++index, (Integer) (rowData.get(COLUMN.PID.ordinal())));
+ prep.setFloat(++index, (Float) (rowData.get(COLUMN.CPU_LOAD.ordinal())));
+ prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_VIRTUAL.ordinal())));
+ prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_RESIDENT.ordinal())));
+ prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_SHARED.ordinal())));
+ prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_PSS.ordinal())));
+ prep.setLong(++index, (Integer) (rowData.get(COLUMN.THREAD_COUNT.ordinal())));
+ prep.setLong(++index, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION_TOTAL_BYTE.ordinal())));
+ SqlConnectionManager.setArrayToPreparedStatement(COLUMN.HEAP_ALLOCATION_NAME.ordinal(),
+ DBConstants.VARCHAR, prep, rowData);
+ SqlConnectionManager.setArrayToPreparedStatement(COLUMN.HEAP_ALLOCATION_BYTE.ordinal(),
+ DBConstants.LONG, prep, rowData);
+ SqlConnectionManager.setArrayToPreparedStatement(COLUMN.THREAD_ID.ordinal(),
+ DBConstants.INTEGER, prep, rowData);
+ SqlConnectionManager.setArrayToPreparedStatement(COLUMN.THREAD_LOAD.ordinal(),
+ DBConstants.FLOAT, prep, rowData);
} catch (SQLException e) {
e.printStackTrace();
isPrepared = false;
import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
+import org.tizen.dynamicanalyzer.project.BinaryInfo;
+import org.tizen.dynamicanalyzer.project.LibraryObject;
+import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants;
+import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
+import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.utils.Formatter;
+import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
public class HeapChart extends TimelineChart {
private static HeapChart instance = null;
- private final int TOTAL_ALLOC = 0;
- private final int USER_ALLOC = 1;
-
- private Map<Integer, DAChartBoardItem> processChartboardMap = new HashMap<Integer, DAChartBoardItem>();
- private Map<Integer, String> processNameMap = new HashMap<Integer, String>();
+ private List<String> librarySequenceList = new ArrayList<String>();
+ // Map<PID, Map<binaryPath, DAChartSeries>>
+ private Map<Integer, Map<String, DAChartSeries>> seriesPerProcessMap = new HashMap<Integer, Map<String, DAChartSeries>>();
private DAChartBoardItem parentBoardItem;
+ private List<DAChartBoardItem> childBoardItemList = new ArrayList<DAChartBoardItem>();
public static HeapChart getInstance() {
if (instance == null) {
return instance;
}
- private List<DAChartSeries> createChartSeries() {
- List<DAChartSeries> chartSeriesList = new ArrayList<DAChartSeries>();
-
+ private Map<String, DAChartSeries> createChartSeries(int pid) {
+ Map<String, DAChartSeries> chartSeriesMap = new HashMap<String, DAChartSeries>();
+ /*
+ * Add total allocation
+ */
DAChartSeries totalAllocationSeries = new DAChartSeries(
- TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION,
- DAChartSeries.SERIES_STYLE_AREA, ColorResources.SERIES_COLOR_HEAP_SYSTEM);
- DAChartSeries userAllocationSeries = new DAChartSeries(
- TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION,
- DAChartSeries.SERIES_STYLE_AREA, ColorResources.SERIES_COLOR_HEAP_USER);
+ TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION, DAChartSeries.SERIES_STYLE_AREA,
+ ColorResources.SERIES_COLOR_HEAP_SYSTEM);
+ chartSeriesMap.put(TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION, totalAllocationSeries);
/*
- * Insert order is important.
+ * Add additional library allocation
*/
- chartSeriesList.add(totalAllocationSeries);
- chartSeriesList.add(userAllocationSeries);
+ HashMap<String, BinaryInfo> binInfoMap = BinarySettingManager.getInstance().getTargetBinInfoMap();
+ ProcessMemoryMap pmap = AnalyzerManager.getProject().getProcessInformation(pid)
+ .getProcessMemoryMap(ToolbarArea.getInstance().getTime());
+ Iterator<String> iter = binInfoMap.keySet().iterator();
+ while (iter.hasNext()) {
+ String libraryPath = iter.next();
+ LibraryObject libObj = pmap.getLibraryByBinaryID(binInfoMap.get(libraryPath).getID());
+ if (null != libObj) {
+ DAChartSeries libraryAllocSeries = new DAChartSeries(libraryPath, DAChartSeries.SERIES_STYLE_AREA);
+ chartSeriesMap.put(libraryPath, libraryAllocSeries);
+ }
+ }
+ /*
+ * Add target allocation
+ */
+ DAChartSeries targetAllocationSeries = new DAChartSeries(
+ TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION, DAChartSeries.SERIES_STYLE_AREA,
+ ColorResources.SERIES_COLOR_HEAP_USER);
+ chartSeriesMap.put(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION, targetAllocationSeries);
- return chartSeriesList;
+ return chartSeriesMap;
}
private HeapChart() {
}
public DAChartBoardItem createChildBoardItem(DAChartBoardItem parent) {
- DAChartBoardItem item = new DAChartBoardItem(parent, chartName, chartIcon,
- chartStyle);
+ DAChartBoardItem item = new DAChartBoardItem(parent, chartName, chartIcon, chartStyle);
chart = item.getChart();
setChartStyle();
popupMenu, parent.getChartBoard().getTimeline());
chart.addMouseListener(timelineChartMouseEventListener);
chart.addMouseMoveListener(timelineChartMouseEventListener);
- chart.addMouseTrackListener(new TimelineChartMouseTrackAdapter(parent
- .getChartBoard().getTimeline()));
+ chart.addMouseTrackListener(new TimelineChartMouseTrackAdapter(parent.getChartBoard().getTimeline()));
return item;
}
/*
* Clear series items
*/
- for (Map.Entry<Integer, DAChartBoardItem> entry : processChartboardMap.entrySet()) {
- DAChartBoardItem board = entry.getValue();
- List<DAChartSeries> seriesList = board.getChart().getSeriesList();
- for (int i = 0; i < seriesList.size(); i++) {
- seriesList.get(i).clear();
+ Iterator<Map<String, DAChartSeries>> iterPerPID = seriesPerProcessMap.values().iterator();
+ while (iterPerPID.hasNext()) {
+ Iterator<DAChartSeries> iterSeries = iterPerPID.next().values().iterator();
+ while (iterSeries.hasNext()) {
+ iterSeries.next().clear();
}
}
if (AnalyzerManager.getProject() == null) {
return;
}
+
@SuppressWarnings("unchecked")
Map<Integer, List<List<Object>>> processDataMap = (Map<Integer, List<List<Object>>>) dataList
.get(TimelineConstants.TARGET_PROCESS_DB_DATA);
-
Iterator<Integer> iterProcessData = processDataMap.keySet().iterator();
while (iterProcessData.hasNext()) {
final Integer pid = iterProcessData.next();
-
+ List<List<Object>> data = processDataMap.get(pid);
/*
* First process, use parentBoardItem.
*/
- if (processChartboardMap.isEmpty()) {
- List<DAChartSeries> seriesList = createChartSeries();
- processChartboardMap.put(pid, parentBoardItem);
- for (int i = 0; i < seriesList.size(); i++) {
- parentBoardItem.getChart().addSeries(seriesList.get(i));
- }
+ if (seriesPerProcessMap.isEmpty()) {
+ Map<String, DAChartSeries> seriesMap = createChartSeries(pid);
+ seriesPerProcessMap.put(pid, seriesMap);
+ setChartSeries(chart, seriesMap);
+ final String processName = AnalyzerUtil.getProcessName(pid.intValue());
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ parentBoardItem.getItemCell().setAdditionalInfo(processName + "\nPID : " + pid.intValue(),
+ ImageResources.CHART_HEAP_SMALL);
+ }
+ });
}
/*
* If new Process created, Create ChartBoardItem, Chart, Series.
*/
- else if (processChartboardMap.get(pid) == null) {
- final List<DAChartSeries> seriesList = createChartSeries();
- HeapChart childChart = new HeapChart();
- DAChartBoardItem childBoardItem = childChart
- .createChildBoardItem(parentBoardItem);
- processChartboardMap.put(pid, childBoardItem);
-
- for (int i = 0; i < seriesList.size(); i++) {
- childBoardItem.getChart().addSeries(seriesList.get(i));
- }
- parentBoardItem.unFoldChild();
- }
-
- final DAChartBoardItem curBoard = processChartboardMap.get(pid);
-
- String oldProcessName = processNameMap.get(pid);
- final String processName = AnalyzerUtil.getProcessName(pid.intValue());
- if (oldProcessName == null || !oldProcessName.equals(processName)) {
+ else if (seriesPerProcessMap.get(pid) == null) {
+ final Map<String, DAChartSeries> seriesMap = createChartSeries(pid);
+ seriesPerProcessMap.put(pid, seriesMap);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- curBoard.getItemCell().setAdditionalInfo(
- processName + "\nPID : " + pid.intValue(),
+ HeapChart childChart = new HeapChart();
+ DAChartBoardItem childBoardItem = childChart.createChildBoardItem(parentBoardItem);
+ setChartSeries(childBoardItem.getChart(), seriesMap);
+ String processName = AnalyzerUtil.getProcessName(pid.intValue());
+ childBoardItem.getItemCell().setAdditionalInfo(processName + "\nPID : " + pid.intValue(),
ImageResources.CHART_HEAP_SMALL);
+ childBoardItemList.add(childBoardItem);
+ parentBoardItem.unFoldChild();
}
});
}
- List<DAChartSeries> seriesList = curBoard.getChart().getSeriesList();
- List<List<Object>> data = processDataMap.get(pid);
+ Map<String, DAChartSeries> seriesMap = seriesPerProcessMap.get(pid);
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
double time = (Long) row.get(TargetProcessDBTable.COLUMN.TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
- long totalAlloc = (Long) row
- .get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_TOTAL.ordinal());
- long userAlloc = (Long) row
- .get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION.ordinal());
-
- seriesList.get(TOTAL_ALLOC).addSeriesItem(
- new DAChartSeriesItem(time, totalAlloc, Formatter
- .toByteFormat(totalAlloc)));
- seriesList.get(USER_ALLOC).addSeriesItem(
- new DAChartSeriesItem(time, userAlloc, Formatter
- .toByteFormat(userAlloc)));
+ long totalAlloc = (Long) row.get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_TOTAL_BYTE.ordinal());
+
+ @SuppressWarnings("unchecked")
+ List<Object> binaryPathList = (List<Object>) row.get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_NAME
+ .ordinal());
+ @SuppressWarnings("unchecked")
+ List<Object> binaryAllocList = (List<Object>) row.get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_BYTE
+ .ordinal());
+
+ DAChartSeries totalAllocSeries = seriesMap
+ .get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION);
+ totalAllocSeries.addSeriesItem(new DAChartSeriesItem(time, totalAlloc, Formatter
+ .toByteFormat(totalAlloc)));
+ long targetAlloc = (Long) binaryAllocList.get(0); // target
+ // allocation
+ // is
+ // located
+ // at first
+ // index.
+ DAChartSeries appAllocSeries = seriesMap.get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION);
+ appAllocSeries.addSeriesItem(new DAChartSeriesItem(time, targetAlloc, Formatter
+ .toByteFormat(targetAlloc)));
+
+ /*
+ * get total user allocation byte (app + library)
+ */
+ long totalUserAlloc = 0;
+ for (int ii = 0; ii < binaryAllocList.size(); ii++) {
+ totalUserAlloc += (Long) binaryAllocList.get(ii);
+ }
+ /*
+ * Set seriesItem for library allocation
+ */
+ long beforeLibraryAlloc = 0; // need to accumulate
+ for (int ii = 0; ii < librarySequenceList.size(); ii++) {
+ String libraryPath = librarySequenceList.get(ii);
+ DAChartSeries allocSeries = seriesMap.get(libraryPath);
+ int index = binaryPathList.indexOf(libraryPath);
+ long libraryAlloc = 0;
+ if (index > 0) {
+ libraryAlloc = (Long) binaryAllocList.get(index);
+ }
+ allocSeries.addSeriesItem(new DAChartSeriesItem(time, totalUserAlloc - beforeLibraryAlloc,
+ Formatter.toByteFormat(libraryAlloc)));
+ beforeLibraryAlloc = libraryAlloc;
+ }
}
}
}
+ private void setChartSeries(DAChart chart, Map<String, DAChartSeries> seriesMap) {
+ chart.addSeries(seriesMap.get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION));
+ Iterator<String> iterSeries = seriesMap.keySet().iterator();
+ while (iterSeries.hasNext()) {
+ String libraryPath = iterSeries.next();
+ if (libraryPath.equals(TimelineChartLabels.HEAP_CHART_SERIES_NAME_TOTAL_ALLOCATION)
+ || libraryPath.equals(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION)) {
+ continue;
+ }
+ chart.addSeries(seriesMap.get(libraryPath));
+ if (librarySequenceList.indexOf(libraryPath) < 0) {
+ librarySequenceList.add(libraryPath);
+ }
+ }
+ chart.addSeries(seriesMap.get(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION));
+ }
+
@Override
public void clear() {
- processChartboardMap.clear();
- processNameMap.clear();
- for (Map.Entry<Integer, DAChartBoardItem> entry : processChartboardMap.entrySet()) {
- DAChartBoardItem board = entry.getValue();
- if (board != parentBoardItem) {
- board.dispose();
- }
+ seriesPerProcessMap.clear();
+ for (int i = 0; i < childBoardItemList.size(); i++) {
+ childBoardItemList.get(i).dispose();
}
}
}
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.database.DBTable;
import org.tizen.dynamicanalyzer.nl.ConfigureLabels;
+import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.project.BinaryInfo;
import org.tizen.dynamicanalyzer.project.LibraryObject;
-import org.tizen.dynamicanalyzer.project.ProcessInformation;
import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants;
import org.tizen.dynamicanalyzer.swap.model.data.ScreenShotData;
import org.tizen.dynamicanalyzer.swap.model.data.SystemData;
import org.tizen.dynamicanalyzer.swap.model.data.UIEventData;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.ui.info.screenshot.SocketClient;
private static final int MEM_API_TYPE_ALLOC = 0;
private static final int MEM_API_TYPE_FREE = 1;
- private static final int MEM_API_TYPE_MANAGE = 2;
private static final int MEM_USER = 2;
- private Map<Integer, Long> allocByteMap = new HashMap<Integer, Long>(); // Map<PID,
- // allocByte>
+ // Map<PID, target Allocation Byte>
+ private Map<Integer, Long> allocByteMap = new HashMap<Integer, Long>();
+ // Map<PID, Map<binaryPath, Allocation Byte>>
+ private Map<Integer, Map<String, Long>> libraryAllocByteMap = new HashMap<Integer, Map<String, Long>>();
+ // Map<Address, Allocation Byte>
private HashMap<Long, Long> allocationSeriesDataSetMap = new HashMap<Long, Long>();
public static TimelineChartManager getInstance() {
initChartMap(ProcessMemoryChart.getInstance());
initChartMap(SystemMemoryChart.getInstance());
initChartMap(ScreenshotChart.getInstance());
-// initChartMap(UIEventChart.getInstance());
+ // initChartMap(UIEventChart.getInstance());
initChartMap(DiskIOChart.getInstance());
initChartMap(NetworkIOChart.getInstance());
-// initChartMap(DeviceChart.getInstance());
+ // initChartMap(DeviceChart.getInstance());
initChartMap(EnergyChart.getInstance());
loadSavedChartList();
strSaveChartNameList.append(","); //$NON-NLS-1$
}
- ConfigureManager.getInstance().setValue(
- ConfigureLabels.CONFIGUREMANAGER_CHART_AVAILABLE_ITEM_LIST,
+ ConfigureManager.getInstance().setValue(ConfigureLabels.CONFIGUREMANAGER_CHART_AVAILABLE_ITEM_LIST,
strSaveChartNameList.toString());
}
}
DAChartBoardItem item = chart.createBoardItem(chartBoard);
DAChart chartWidget = item.getChart();
- chartWidget.getPlot().setAxisRangeX(chartBoard.getVisibleStartTime(),
- chartBoard.getVisibleEndTime());
+ chartWidget.getPlot().setAxisRangeX(chartBoard.getVisibleStartTime(), chartBoard.getVisibleEndTime());
chartWidget.getPlot().setMarkers(chartBoard.getMarkers());
TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
chart.getPopupMenu(), chartBoard.getTimeline());
chartWidget.addMouseListener(timelineChartMouseEventListener);
chartWidget.addMouseMoveListener(timelineChartMouseEventListener);
- chartWidget.addMouseTrackListener(new TimelineChartMouseTrackAdapter(chartBoard
- .getTimeline()));
+ chartWidget.addMouseTrackListener(new TimelineChartMouseTrackAdapter(chartBoard.getTimeline()));
}
StringBuffer selectedChartNameList = new StringBuffer(""); //$NON-NLS-1$
selectedChartNameList.append(selectedChart.getChartName());
selectedChartNameList.append(","); //$NON-NLS-1$
}
- ConfigureManager.getInstance().setValue(
- ConfigureLabels.CONFIGUREMANAGER_CHART_SELECTED_ITEM_LIST,
+ ConfigureManager.getInstance().setValue(ConfigureLabels.CONFIGUREMANAGER_CHART_SELECTED_ITEM_LIST,
selectedChartNameList.toString());
// AnalyzerUtil.getTimelineComposite().resetItems();
for (TimelineChart timelineChart : chartList) {
if (timelineChart instanceof UserCustomChart) {
UserCustomChart customChart = (UserCustomChart) timelineChart;
- ArrayList<DAChartSeries> tempSeriesList = (ArrayList<DAChartSeries>) customChart
- .getTempSeries().clone();
+ ArrayList<DAChartSeries> tempSeriesList = (ArrayList<DAChartSeries>) customChart.getTempSeries()
+ .clone();
((UserCustomChart) timelineChart).getTempSeries().clear();
for (DAChartSeries series : tempSeriesList) {
customChart.addSeries(series);
customLogParser.clear();
allocByteMap.clear();
+ libraryAllocByteMap.clear();
allocationSeriesDataSetMap.clear();
}
MemoryData logData = (MemoryData) memoryLogList.get(i);
if (allocByteMap.get(logData.getPid()) == null) {
allocByteMap.put(Integer.valueOf(logData.getPid()), new Long(0));
+ libraryAllocByteMap.put(Integer.valueOf(logData.getPid()), new HashMap<String, Long>());
}
int memApiType = logData.getMemoryApiType();
int internalFlag = logData.getInternalCall();
long errorNo = logData.getErrno();
+
+ /*
+ * Check library allocation
+ */
+ String binaryPath = null;
+ Project project = AnalyzerManager.getProject();
+ ProcessMemoryMap pmap = project.getProcessInformation(logData.getPid()).getProcessMemoryMap(
+ logData.getTime());
+ LibraryObject lib = pmap.getLibraryByAddress(logData.getCallerPcAddr());
+ if (lib != pmap.getMainbinary()) {
+ BinaryInfo binfo = project.getDeviceStatusInfo().getBinaryInfo(lib.getBinaryID());
+ binaryPath = binfo.getTargetBinaryPath();
+ }
if (errorNo == 0 && MEM_USER == internalFlag) {
- if (MEM_API_TYPE_ALLOC == memApiType || MEM_API_TYPE_FREE == memApiType
- || MEM_API_TYPE_MANAGE == memApiType) {
-
- addNewSeriesUserAllocData(memApiType, logData);
+ if (MEM_API_TYPE_ALLOC == memApiType || MEM_API_TYPE_FREE == memApiType) {
+ addNewSeriesUserAllocData(memApiType, logData, binaryPath);
}
}
}
*/
ArrayList<Object> energyUsageDeviceList = new ArrayList<Object>();
ArrayList<Object> energyUsageAppList = new ArrayList<Object>();
- String[] deviceEnergyUsages = log.getDeviceEnergyUsage().split(
- CommonConstants.COMMA);
- String[] deviceEnergyUsagesPerApp = log.getApplicationEnergyUsage().split(
- CommonConstants.COMMA);
+ String[] deviceEnergyUsages = log.getDeviceEnergyUsage().split(CommonConstants.COMMA);
+ String[] deviceEnergyUsagesPerApp = log.getApplicationEnergyUsage().split(CommonConstants.COMMA);
for (int ii = 0; ii < deviceEnergyUsages.length; ii++) {
energyUsageDeviceList.add(new Long(deviceEnergyUsages[ii]));
energyUsageAppList.add(new Long(deviceEnergyUsagesPerApp[ii]));
dbTargetProcessData.add(new Long(process.getResidentMemory()));
dbTargetProcessData.add(new Long(process.getSharedMemory()));
dbTargetProcessData.add(new Long(process.getPssMemory()));
+ dbTargetProcessData.add(new Integer(process.getThreadCount()));
dbTargetProcessData.add(new Long(process.getTotalAllocSize()));
+ /*
+ * Set inform for Heap allocation
+ */
+ List<Object> binaryPathList = new ArrayList<Object>();
+ List<Object> allocByteList = new ArrayList<Object>();
+ binaryPathList.add(TimelineChartLabels.HEAP_CHART_SERIES_NAME_APP_ALLOCATION);
if (allocByteMap.get(process.getPid()) == null) {
- dbTargetProcessData.add(new Long(0));
+ allocByteList.add(new Long(0));
} else {
- dbTargetProcessData.add(allocByteMap.get(process.getPid()));
+ allocByteList.add(allocByteMap.get(process.getPid()));
}
-
+ Map<String, Long> libraryList = libraryAllocByteMap.get(process.getPid());
+ if (libraryList == null) {
+ libraryList = new HashMap<String, Long>();
+ }
+ Iterator<String> iter = libraryList.keySet().iterator();
+ while (iter.hasNext()) {
+ String binaryPath = iter.next();
+ binaryPathList.add(binaryPath);
+ allocByteList.add(libraryList.get(binaryPath));
+ }
+ dbTargetProcessData.add(binaryPathList);
+ dbTargetProcessData.add(allocByteList);
+
+ /*
+ * Set inform for Thread
+ */
+ List<Object> threadIdList = new ArrayList<Object>();
+ List<Object> threadLoadList = new ArrayList<Object>();
+ // TODO Remove unnecessary String parsing. first Fix in SystemData.java
+ String[] threadLoads = process.getThreadLoad().split(CommonConstants.COMMA);
+ for (int iii = 0; iii < threadLoads.length; iii++) {
+ String threadLoad = threadLoads[iii];
+ if (threadLoad == null || threadLoad.isEmpty()) {
+ continue;
+ }
+ threadIdList.add(new Integer(threadLoad));
+ threadLoadList.add(threadLoads[++iii]);
+ }
+ dbTargetProcessData.add(threadIdList);
+ dbTargetProcessData.add(threadLoadList);
+
targetProcessDataList.add(dbTargetProcessData);
}
}
}
private void makeScreenShotDBTableData(Logs screenShotLogs) {
- List<LogData> screenShotLogList = screenShotLogs == null ? null : screenShotLogs
- .getRawLogs();
+ List<LogData> screenShotLogList = screenShotLogs == null ? null : screenShotLogs.getRawLogs();
if (screenShotLogList != null) {
ArrayList<List<Object>> screenShotDataList = new ArrayList<List<Object>>();
int size = screenShotLogList.size();
ArrayList<Object> dbScreenShotData = new ArrayList<Object>();
String imagePathLog = null;
if (DACommunicator.isTargetEmulator() && SocketClient.getInstance().isConnected()) {
- imagePathLog = GlobalInformation.getCurrentDeviceInfo().emulatorScreenshot
- .getFilePath();
+ imagePathLog = GlobalInformation.getCurrentDeviceInfo().emulatorScreenshot.getFilePath();
} else {
imagePathLog = log.getImageFilePath();
}
}
}
- private void addNewSeriesUserAllocData(int fdApiType, MemoryData log) {
+ private void addNewSeriesUserAllocData(int fdApiType, MemoryData log, String libraryPath) {
long size = 0;
Long allocByte = allocByteMap.get(log.getPid());
if (MEM_API_TYPE_ALLOC == fdApiType) {
try {
size = log.getSize();
- allocByteMap.put(log.getPid(), allocByte + size);
+ if (libraryPath == null) {
+ allocByteMap.put(log.getPid(), allocByte + size);
+ } else {
+ Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(libraryPath);
+ if (libraryAllocByte == null) {
+ libraryAllocByte = new Long(0);
+ }
+ libraryAllocByteMap.get(log.getPid()).put(libraryPath, libraryAllocByte + size);
+ }
allocationSeriesDataSetMap.put(address, size);
} catch (NumberFormatException ne) {
ne.printStackTrace();
return;
}
size = allocationSeriesDataSetMap.get(address);
- allocByteMap.put(log.getPid(), allocByte - size);
+
+ if (libraryPath == null) {
+ allocByteMap.put(log.getPid(), allocByte - size);
+ } else {
+ Long libraryAllocByte = libraryAllocByteMap.get(log.getPid()).get(libraryPath);
+ libraryAllocByteMap.get(log.getPid()).put(libraryPath, libraryAllocByte - size);
+ }
}
}
}
public List<List<Object>> getSystemDataFromDB(long start, long end) {
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + SystemDataDBTable.TIME;
+ String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + SystemDataDBTable.TIME;
List<List<Object>> result = systemDataTable.selectData(null, where);
if (result != null) {
}
public List<List<Object>> getUIEventDataFromDB(long start, long end) {
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + UIEventDBTable.TIME;
+ String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + UIEventDBTable.TIME;
List<List<Object>> result = uiEventDBTable.selectData(null, where);
if (result != null) {
}
public List<List<Object>> getScreenShotDataFromDB(long start, long end) {
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + ScreenShotDBTable.TIME;
+ String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + ScreenShotDBTable.TIME;
List<List<Object>> result = screenShotDBTable.selectData(null, where);
if (result != null) {
}
public List<List<Object>> getCustomDataFromDB(long start, long end) {
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + CustomDataDBTable.TIME;
+ String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + CustomDataDBTable.TIME;
List<List<Object>> result = customDataDBTable.selectData(null, where);
if (result != null) {
public Map<Integer, List<List<Object>>> getTargetProcessDataFromDB(long start, long end) {
Map<Integer, List<List<Object>>> processedResult = new HashMap<Integer, List<List<Object>>>();
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + TargetProcessDBTable.TIME;
+ String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + TargetProcessDBTable.TIME;
List<List<Object>> queryResult = targetProcessDBTable.selectData(null, where);
if (queryResult == null) {
return processedResult;
List<List<Object>> uiEventDBData = getUIEventDataFromDB(startTime, endTime);
List<List<Object>> screenShotDBData = getScreenShotDataFromDB(startTime, endTime);
List<List<Object>> customDBData = getCustomDataFromDB(startTime, endTime);
- Map<Integer, List<List<Object>>> targetProcessDBData = getTargetProcessDataFromDB(
- startTime, endTime);
+ Map<Integer, List<List<Object>>> targetProcessDBData = getTargetProcessDataFromDB(startTime, endTime);
/*
* 2. Make series of chart