diff -r 5b9d4d8641ce -r ae255c9aa552 sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi/src/com/nokia/carbide/cpp/internal/pi/model/ProfiledThread.java --- a/sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi/src/com/nokia/carbide/cpp/internal/pi/model/ProfiledThread.java Wed Jun 23 14:49:59 2010 +0300 +++ b/sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi/src/com/nokia/carbide/cpp/internal/pi/model/ProfiledThread.java Wed Jun 23 15:05:09 2010 +0300 @@ -19,19 +19,21 @@ import java.io.Serializable; -/* - * - * PRI HOMMAT KOMMENTOITU TÄSTÄ FILESTÄ TOISTAISEKSI - * - */ +import org.eclipse.core.runtime.Platform; -public class ProfiledThread extends ProfiledGeneric implements Serializable +import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository; +import com.nokia.carbide.cpp.pi.PiPlugin; + + +public class ProfiledThread extends ProfiledGeneric implements Serializable, ICPUScaleAdapter { private static final long serialVersionUID = 20150633093396772L; private char name; //char symbol of the thread private int threadId; //thread's real id + + private float[] calculatedActivity; public ProfiledThread(int cpuCount, int graphCount) { @@ -70,4 +72,66 @@ { this.threadId = threadId; } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.internal.pi.model.ProfiledGeneric#getActivityList() + */ + @Override + public float[] getActivityList() { + float[] activityList = super.getActivityList(); + + boolean scaleCPU = isScaledCpu(); + if(scaleCPU){ + Object object = getAdapter(ICPUScale.class); + if(object instanceof ICPUScale){ + ICPUScale cpuScale = (ICPUScale) object; + if(calculatedActivity != null && calculatedActivity.length == activityList.length){ + activityList = calculatedActivity; + }else{ + int[] sampleList = getSampleList(); + for (int i = 0; i < sampleList.length; i++) { + float value = activityList[i] / 100; + value = value * cpuScale.calculateScale(sampleList[i]) * 100; + activityList[i] = value; + } + calculatedActivity = activityList; + } + } + } + + return activityList; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + @SuppressWarnings("unchecked") + public Object getAdapter(Class adapter) { + if(adapter == null){ + return null; + } + return Platform.getAdapterManager().loadAdapter(this, adapter.getName()); + } + + /** + * Check are threads scaled or not + * + * @return + */ + public boolean isScaledCpu(){ + boolean scaleCPU = false; + + Object obj = NpiInstanceRepository.getInstance().activeUidGetPersistState( + PiPlugin.ACTION_SCALE_CPU); + if ((obj != null) && (obj instanceof Boolean)){ + // retrieve the current value + scaleCPU = (Boolean) obj; + }else{ + // set the initial value + NpiInstanceRepository.getInstance().activeUidSetPersistState( + PiPlugin.ACTION_SCALE_CPU, scaleCPU); + } + return scaleCPU; + } }