* SystemData.getTotalCPULoad() - fixed to return scaled CPU load in range 0-100.
* CPUChart.inputChartSeries() - fixed calculation of appLoadSeries data:
removed unneeded division by cores number.
* Comments added/updated to specify CPU load value range.
Change-Id: Ie939e1b14899a9215a25b7a1e99467894742dada
public class ProcessProfileData {
private int pid; // protocol 3.0
- private float processLoad; // protocol 3.0
+ private float processLoad; // protocol 3.0, in range [0-100]%
private long virtualMemory; // protocol 3.0
private long residentMemory; // protocol 3.0
private long sharedMemory; // protocol 3.0
}
double[] cpuFrequency = null; // protocol 3.0
- double[] cpuLoad = null; // protocol 3.0
+ double[] cpuLoad = null; // protocol 3.0 , in range [0-100]%
long systemMemoryUsed = 0; // protocol 3.0
int targetProcessCount = 0; // protocol 3.0
ProcessProfileData[] processProfileDataList = null; // protocol 3.0
this.otherProcessLoad = otherProcessLoad;
}
+ /**
+ * Get total system CPU load value.
+ * @return percentage of CPU load, scaled by number of CPU cores to be in range [0-100]%
+ */
public double getTotalCPULoad() {
if (cpuLoad == null) {
return 0.0;
}
+
+ // Calculate CPU load based on each core load information
double totalCPULoad = 0.0;
for (int i = 0; i < cpuLoad.length; i++) {
totalCPULoad += cpuLoad[i];
}
+ // Each core CPU load is in range 0-100%, so the sum should be scaled by CPU number
+ totalCPULoad /= cpuLoad.length;
+
+ // Calculate CPU load based on each process load information
double processCPULoad = getProcessCPULoad();
+
+ /*
+ * Revise "total cpu load" to prevent "total load" from being shown less than
+ * "process load". This problem occurs because time gap of calculating "total load"
+ * and "process load".
+ */
if (totalCPULoad < processCPULoad) {
Logger.warning("totalCPULoad [" + totalCPULoad + "] is less than processCPULoad [ + "
+ processCPULoad + "].");
- /*
- * Revise "total cpu load" to prevent "total load" from being shown less than
- * "process load". This problem is occurs because time gap of calculating "total load"
- * and "process load".
- */
totalCPULoad = processCPULoad;
}
return totalCPULoad;
import org.tizen.dynamicanalyzer.database.DBTable;
import org.tizen.dynamicanalyzer.util.Logger;
+/**
+ * DB table representing the system information summarized for all running
+ * processes.
+ */
public class SystemDataDBTable extends DBTable {
private static final String TABLENAME = "TIMELINE_SYSTEM_DATA";
public static enum COLUMN {
SAMPLING_TIME,
+ // CPU load in %, scaled by number of CPU cores to be in range [0-100]%
CPU_LOAD_TOTAL,
PROCESS_COUNT_OTHER,
PROCESS_COUNT_TARGET,
import org.tizen.dynamicanalyzer.database.DBTable;
import org.tizen.dynamicanalyzer.util.Logger;
+/**
+ * DB table representing system information for a process of traced application
+ * (aka "target process")
+ */
public class TargetProcessDBTable extends DBTable {
private static final String TABLENAME = "TIMELINE_TARGET_PROCESS";
public static enum COLUMN {
SAMPLING_TIME,
PID,
+ // CPU load in %, scaled by number of CPU cores to be in range [0-100]%
CPU_LOAD,
MEMORY_VIRTUAL,
MEMORY_RESIDENT,
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
public class CPUChart extends TimelineChart {
+ /**
+ * For each time moment this series presents
+ * the summary CPU load(%) for all processes of traced application.
+ * The CPU load is scaled by number of CPU cores to be in range [0-100]%
+ */
private DAChartSeries appLoadSeries;
+ /**
+ * For each time moment this series presents
+ * the summary CPU load(%) for all processes in system.
+ * The CPU load is scaled by number of CPU cores to be in range [0-100]%
+ */
private DAChartSeries totalLoadSeries;
private DAChartBoard chartBoard = null;
/ TimelineConstants.MEGA_DOUBLE;
try {
+ // systemAvgLoad is already scaled by number of CPU cores to be in range [0-100]%
double systemAvgLoad = (Float) row.get(SystemDataDBTable.COLUMN.CPU_LOAD_TOTAL
.ordinal());
totalLoadSeries.addSeriesItem(new DAChartSeriesItem(time, systemAvgLoad, Formatter
for (int i = 0; i < data.size(); i++) {
List<Object> oneTime = data.get(i);
Long time = (Long) oneTime.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME.ordinal());
+ // cpuLoad is already scaled by number of CPU cores to be in range [0-100]%
Float cpuLoad = (Float) oneTime.get(TargetProcessDBTable.COLUMN.CPU_LOAD.ordinal());
Float processLoadSum = processLoadSumMap.get(time);
if (processLoadSum == null) {
Iterator<Long> iterProcessLoadSum = timeSortedLoadList.iterator();
while (iterProcessLoadSum.hasNext()) {
Long time = iterProcessLoadSum.next();
+ // cpuLoadSum is already scaled by number of CPU cores to be in range [0-100]%
Float cpuLoadSum = processLoadSumMap.get(time);
- double cpuAvgLoad = cpuLoadSum / coreSize;
appLoadSeries.addSeriesItem(new DAChartSeriesItem(time / TimelineConstants.MEGA_DOUBLE,
- cpuAvgLoad, Formatter.toPercentageFormat(cpuAvgLoad)));
+ cpuLoadSum.doubleValue(), Formatter.toPercentageFormat(cpuLoadSum.doubleValue())));
}
if (prevChildSize != childSeriesMap.size()) {
/*
* Make SystemData Table data
*/
- double systemAvgCPULoad = log.getTotalCPULoad() / coreSize;
+ // systemAvgCPULoad is already scaled by number of CPU cores to be in range [0-100]%
+ double systemAvgCPULoad = log.getTotalCPULoad();
ArrayList<Object> dbSystemData = new ArrayList<Object>();
dbSystemData.add(new Long(log.getTime()));
dbSystemData.add(new Float(systemAvgCPULoad));