Remove doCPUID caching, to due to having to much overhead compared to acutally just doing the doCPUID every time.

This commit is contained in:
dev
2011-06-08 08:25:09 +00:00
parent 831848e938
commit 3a5347f88f

View File

@ -56,7 +56,6 @@ public class CPUID {
private static final boolean isFreebsd = System.getProperty("os.name").toLowerCase().contains("freebsd");
private static final boolean isSunos = System.getProperty("os.name").toLowerCase().contains("sunos");
private static final HashMap<Integer,CPUIDResult> cpuidCache = new HashMap<Integer,CPUIDResult>();
/**
* This isn't always correct.
@ -98,21 +97,10 @@ public class CPUID {
*/
private static native CPUIDResult doCPUID(int iFunction);
private static CPUIDResult cachedCPUID(int iFunction)
{
CPUIDResult cachedCPUID = cpuidCache.get(iFunction);
if (cachedCPUID != null)
return cachedCPUID;
else {
CPUIDResult c = doCPUID(iFunction);
cpuidCache.put(iFunction,c);
return c;
}
}
private static String getCPUVendorID()
{
CPUIDResult c = cachedCPUID(0);
CPUIDResult c = doCPUID(0);
StringBuilder sb= new StringBuilder(13);
sb.append((char)( c.EBX & 0xFF));
sb.append((char)((c.EBX >> 8) & 0xFF));
@ -133,54 +121,58 @@ public class CPUID {
}
private static int getCPUFamily()
{
CPUIDResult c = cachedCPUID(1);
CPUIDResult c = doCPUID(1);
return (c.EAX >> 8) & 0xf;
}
private static int getCPUModel()
{
CPUIDResult c = cachedCPUID(1);
CPUIDResult c = doCPUID(1);
return (c.EAX >> 4) & 0xf;
}
private static int getCPUExtendedModel()
{
CPUIDResult c = cachedCPUID(1);
CPUIDResult c = doCPUID(1);
return (c.EAX >> 16) & 0xf;
}
private static int getCPUType()
{
CPUIDResult c = cachedCPUID(1);
CPUIDResult c = doCPUID(1);
return (c.EAX >> 12) & 0xf;
}
private static int getCPUExtendedFamily()
{
CPUIDResult c = cachedCPUID(1);
CPUIDResult c = doCPUID(1);
return (c.EAX >> 20) & 0xff;
}
private static int getCPUStepping()
{
CPUIDResult c = cachedCPUID(1);
CPUIDResult c = doCPUID(1);
return c.EAX & 0xf;
}
private static int getEDXCPUFlags()
{
CPUIDResult c = cachedCPUID(1);
CPUIDResult c = doCPUID(1);
return c.EDX;
}
private static int getECXCPUFlags()
{
CPUIDResult c = cachedCPUID(1);
CPUIDResult c = doCPUID(1);
return c.ECX;
}
private static int getExtendedEBXCPUFlags()
{
private static int getExtendedECXCPUFlags()
{
CPUIDResult c = doCPUID(0x80000001);
return c.ECX;
}
private static int getExtendedEDXCPUFlags()
{
CPUIDResult c = cachedCPUID(0x80000001);
CPUIDResult c = doCPUID(0x80000001);
return c.EDX;
}
private static int getExtendedECXCPUFlags()
{
CPUIDResult c = cachedCPUID(0x80000001);
return c.ECX;
}
//Returns a CPUInfo item for the current type of CPU
//If I could I would declare this method in a interface named