os.linux: Rename the "kernelanalysis" package to just "kernel"
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / analysis / os / linux / core / cpuusage / KernelCpuUsageStateProvider.java
index 3de733949d3c139e8ab48eb4d28eb298d628e9ee..03013893a63606a0188fb735ab2487972ca9690e 100644 (file)
@@ -19,13 +19,12 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernel.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;
@@ -91,12 +90,11 @@ public class KernelCpuUsageStateProvider extends AbstractTmfStateProvider {
         final String eventName = event.getName();
 
         if (eventName.equals(fLayout.eventSchedSwitch())) {
-            Object cpuObj = TmfTraceUtils.resolveEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event);
-            if (cpuObj == null) {
+            Integer cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event);
+            if (cpu == null) {
                 /* We couldn't find any CPU information, ignore this event */
                 return;
             }
-            Integer cpu = (Integer) cpuObj;
 
             /*
              * Fields: string prev_comm, int32 prev_tid, int32 prev_prio, int64
@@ -126,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.027408 seconds and 5 git commands to generate.