analysis.os: Make the CPU usage state provider use the increment method
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Fri, 19 Feb 2016 16:05:22 +0000 (11:05 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Tue, 8 Mar 2016 13:42:41 +0000 (08:42 -0500)
Change-Id: If6fed23d4656a7cb233f002e1321ea4d7ac5852f
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/66945
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/cpuusage/KernelCpuUsageStateProvider.java

index e5c8f97d3cb8d84571969a7a420e3107f7cf7454..ca08607bd3b41632511f7e5d543a1023d306bbb6 100644 (file)
@@ -23,9 +23,8 @@ import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
+import org.eclipse.tracecompass.statesystem.core.StateSystemBuilderUtils;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect;
@@ -125,22 +124,13 @@ public class KernelCpuUsageStateProvider extends AbstractTmfStateProvider {
                     startTime = fTraceStart;
                 }
 
-                /*
-                 * We add the time from startTime until now to the cumulative
-                 * time of the thread
-                 */
-                ITmfStateValue value = ss.queryOngoingState(cumulativeTimeQuark);
-
                 /*
                  * Modify cumulative time for this CPU/TID combo: The total time
                  * changes when the process is scheduled out. Nothing happens
                  * when the process is scheduled in.
                  */
-                long prevCumulativeTime = Math.max(0, value.unboxLong());
-                long newCumulativeTime = prevCumulativeTime + (ts - startTime);
+                StateSystemBuilderUtils.incrementAttributeLong(ss, ts, cumulativeTimeQuark, ts - startTime);
 
-                value = TmfStateValue.newValueLong(newCumulativeTime);
-                ss.modifyAttribute(ts, value, cumulativeTimeQuark);
                 fLastStartTimes.put(cpu, ts);
 
             } catch (AttributeNotFoundException e) {
This page took 0.026712 seconds and 5 git commands to generate.