Ejemplo n.º 1
0
        private uint GetCacheSize(CPUCacheLevel level)
        {
            uint value = 0;

            if (cacheSizes.TryGetValue(level, out value))
            {
                return(value);
            }

            return(0);
        }
Ejemplo n.º 2
0
        private Dictionary <CPUCacheLevel, uint> CacheSizes()
        {
            Dictionary <CPUCacheLevel, uint> cacheSizes = new Dictionary <CPUCacheLevel, uint>();

            ManagementClass            management = new ManagementClass("Win32_CacheMemory");
            ManagementObjectCollection collection = management.GetInstances();

            ManagementObjectCollection.ManagementObjectEnumerator enumerator = collection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                PropertyDataCollection properties = enumerator.Current.Properties;

                CPUCacheLevel level = (CPUCacheLevel)((ushort)properties["Level"].Value);
                uint          size  = (uint)properties["MaxCacheSize"].Value;

                cacheSizes.Add(level, size);
            }

            return(cacheSizes);
        }