private void PopulateHardwareInfo()
        {
            Configuration = SystemUtils.GetComputerConfiguration();

            OperatingSystemInfo      operatingSystem = Configuration.OperatingSystem;
            List <CpuInfo>           processors      = Configuration.Processors;
            List <RamInfo>           memory          = Configuration.MemoryModules;
            List <StorageDeviceInfo> storage         = Configuration.StorageDevices;

            // OS
            txtBoxOsName.Text = operatingSystem.Name;
            txtBoxOsType.Text = operatingSystem.Is64bit ? "64 bit" : "32 bit";

            // CPU
            CpuInfo cpu = processors.First();

            txtBoxCpuName.Text      = cpu.Name;
            txtBoxCpuFrequency.Text = String.Format("{0} MHz", cpu.MaxClockSpeed);
            txtBoxCpuThreads.Text   = cpu.Threads.ToString();
            txtBoxCpuCount.Text     = processors.Count.ToString();

            // RAM
            RamInfo ram = memory.First();

            int capacity = 0;

            foreach (var bank in memory)
            {
                capacity += bank.Capacity;
            }

            txtBoxMemoryCapacity.Text  = String.Format("{0} GB", capacity);
            txtBoxMemoryType.Text      = ram.MemoryType.ToString();
            txtBoxMemoryFrequency.Text = String.Format("{0} MHz", ram.Speed);
            txtBoxMemoryBanks.Text     = memory.Count.ToString();

            // STORAGE
            string            benchmarkDataDirectoryRoot = Path.GetPathRoot(BenchmarkTests.First().Database.DataDirectory);
            StorageDeviceInfo dataDrive = storage.Find(drive => drive.DriveLetters.Contains(benchmarkDataDirectoryRoot.Trim('\\')));

            comboBoxStorageModel.Items.AddRange(storage.Select(device => device.Model).ToArray());
            int selectedIndex = comboBoxStorageModel.Items.IndexOf(dataDrive.Model);

            comboBoxStorageModel.SelectedIndex = selectedIndex;

            txtBoxHddSize.Text = String.Format("{0} GB", dataDrive.Size);
        }
Пример #2
0
        /// <summary>
        /// Gets a list of the current processors installed on the machine.
        /// </summary>
        public static List <CpuInfo> GetProcessors()
        {
            List <CpuInfo> processors = null;

            ManagementObjectSearcher processorQuery = new ManagementObjectSearcher(

                @"SELECT
                        Name,
                        NumberOfLogicalProcessors,
                        MaxClockSpeed                 
                    FROM Win32_Processor"
                );

            try
            {
                ManagementObjectCollection processorInfo = processorQuery.Get();

                processors = new List <CpuInfo>();
                foreach (ManagementObject item in processorInfo)
                {
                    CpuInfo cpu = new CpuInfo();

                    cpu.Name          = item["Name"].ToString();
                    cpu.Threads       = Int32.Parse(item["NumberOfLogicalProcessors"].ToString());
                    cpu.MaxClockSpeed = Int32.Parse(item["MaxClockSpeed"].ToString());

                    processors.Add(cpu);
                }
            }
            catch (Exception exc)
            {
                Logger.Error("GetProcessors() error...", exc);
                processors = null;
            }

            return(processors);
        }
Пример #3
0
        public static void ExportComputerConfiguration(StreamWriter writer, ComputerConfiguration computerInfo)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Computer specification:");
            builder.AppendLine("Operating system:;;;Processors:;;;;Memory modules:;;;;Storages:");
            builder.AppendLine("Name;Is64Bit;;Name;Threads;Max clock speed (MHz);;Type;Capacity (GB);Speed (MHz);;Model;Size (GB);Partitions;");

            builder.Append(computerInfo.OperatingSystem.Name + ";");
            builder.Append(computerInfo.OperatingSystem.Is64bit + ";;");

            CpuInfo firstProcessor = computerInfo.Processors.First();

            builder.Append(firstProcessor.Name + ";");
            builder.Append(firstProcessor.Threads + ";");
            builder.Append(firstProcessor.MaxClockSpeed + ";;");

            RamInfo firstRam = computerInfo.MemoryModules.First();

            builder.Append(firstRam.MemoryType + ";");
            builder.Append(firstRam.Capacity + ";");
            builder.Append(firstRam.Speed + ";;");

            StorageDeviceInfo firstStorage = computerInfo.StorageDevices.First();

            builder.Append(firstStorage.Model + ";");
            builder.Append(firstStorage.Size + ";");
            firstStorage.DriveLetters.ForEach(x => builder.Append(x.Replace(":", "")));

            builder.Append(Environment.NewLine);

            int count = Math.Max(Math.Max(computerInfo.Processors.Count, computerInfo.MemoryModules.Count), computerInfo.StorageDevices.Count);

            for (int i = 1; i < count; i++)
            {
                builder.Append(";;;");

                if (computerInfo.Processors.Count <= i)
                {
                    builder.Append(";;;;");
                }
                else
                {
                    CpuInfo info = computerInfo.Processors[i];

                    builder.Append(info.Name + ";");
                    builder.Append(info.Threads + ";");
                    builder.Append(info.MaxClockSpeed + ";;");
                }

                if (computerInfo.MemoryModules.Count <= i)
                {
                    builder.Append(";;;;");
                }
                else
                {
                    RamInfo info = computerInfo.MemoryModules[i];

                    builder.Append(firstRam.MemoryType + ";");
                    builder.Append(firstRam.Capacity + ";");
                    builder.Append(firstRam.Speed + ";;");
                }

                if (computerInfo.StorageDevices.Count <= i)
                {
                    builder.Append(";;;;");
                }
                else
                {
                    StorageDeviceInfo info = computerInfo.StorageDevices[i];
                    builder.Append(info.Model + ";");
                    builder.Append(info.Size + ";");
                    info.DriveLetters.ForEach(x => builder.Append(x));
                }
            }

            writer.WriteLine(builder.ToString());
        }
        /// <summary>
        /// Gets a list of the current processors installed on the machine.
        /// </summary>
        public static List<CpuInfo> GetProcessors()
        {
            List<CpuInfo> processors = null;

            ManagementObjectSearcher processorQuery = new ManagementObjectSearcher(

                   @"SELECT
                        Name,
                        NumberOfLogicalProcessors,
                        MaxClockSpeed
                    FROM Win32_Processor"
            );

            try
            {
                ManagementObjectCollection processorInfo = processorQuery.Get();

                processors = new List<CpuInfo>();
                foreach (ManagementObject item in processorInfo)
                {
                    CpuInfo cpu = new CpuInfo();

                    cpu.Name = item["Name"].ToString();
                    cpu.Threads = Int32.Parse(item["NumberOfLogicalProcessors"].ToString());
                    cpu.MaxClockSpeed = Int32.Parse(item["MaxClockSpeed"].ToString());

                    processors.Add(cpu);
                }
            }
            catch (Exception exc)
            {
                Logger.Error("GetProcessors() error...", exc);
                processors = null;
            }

            return processors;
        }