• 大小: 37.91MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-10
  • 语言: 其他
  • 标签: CPU使用率  

资源简介

获取多核CPU使用率,设置CPU亲和性,设置并发线程数和优先级,绑定线程在特点CPU上运行,并测试

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Diagnostics;
using System.Threading;

namespace CpuUsagePercent
{
    public class CCpuUsagePercent
    {
        private int m_PhysicsProcessorNum;

        private double[] dbUsage;

        public CCpuUsagePercent()
        {
            m_PhysicsProcessorNum = System.Environment.ProcessorCount;
            dbUsage = new double[m_PhysicsProcessorNum];
        }

        public int getPhysicsProcessorNum()
        {
            return m_PhysicsProcessorNum;
        }

        private void getCpuUsage()
        {
            PerformanceCounter[] counters = new PerformanceCounter[m_PhysicsProcessorNum];

            for (int i = 0; i < counters.Length; i++)
            {
                counters[i] = new PerformanceCounter(“Processor“ “% Processor Time“ i.ToString());
            }

            Thread.Sleep(100);
    
             for (int i = 0; i < counters.Length; i++)
             {
                 dbUsage[i]= counters[i].NextValue();
                  
             }
        }

        public double getUsageByIndex(int index)
        {
            if(index==0)
                getCpuUsage();

            return dbUsage[index];
        }

    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件   68571136  2015-06-10 11:00  SystemInfoDemo\SystemInfoDemo.sdf

     文件       3606  2015-04-28 11:49  SystemInfoDemo\SystemInfoDemo.sln

    ..A..H.     45568  2015-06-10 11:00  SystemInfoDemo\SystemInfoDemo.suo

     文件       1329  2015-04-24 14:22  SystemInfoDemo\CpuUsage\CCpuUsagePercent.cs

     文件       2330  2015-04-24 14:16  SystemInfoDemo\CpuUsage\CCpuUsagePercent.csproj

     文件       4608  2015-04-24 14:22  SystemInfoDemo\CpuUsage\bin\Release\CCpuUsagePercent.dll

     文件      11776  2015-04-24 14:22  SystemInfoDemo\CpuUsage\bin\Release\CCpuUsagePercent.pdb

     文件       5615  2015-04-27 09:27  SystemInfoDemo\CpuUsage\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        390  2015-04-24 14:22  SystemInfoDemo\CpuUsage\obj\Release\CCpuUsagePercent.csproj.FileListAbsolute.txt

     文件       4608  2015-04-24 14:22  SystemInfoDemo\CpuUsage\obj\Release\CCpuUsagePercent.dll

     文件      11776  2015-04-24 14:22  SystemInfoDemo\CpuUsage\obj\Release\CCpuUsagePercent.pdb

     文件        358  2015-04-24 14:15  SystemInfoDemo\CpuUsage\obj\Release\CpuUsage.csproj.FileListAbsolute.txt

     文件       5619  2015-04-27 09:27  SystemInfoDemo\CpuUsage\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1368  2015-04-24 12:35  SystemInfoDemo\CpuUsage\Properties\AssemblyInfo.cs

     文件      40448  2015-04-28 12:39  SystemInfoDemo\Debug\TestDemo.exe

     文件     393480  2015-04-28 12:39  SystemInfoDemo\Debug\TestDemo.ilk

     文件     633856  2015-04-28 12:39  SystemInfoDemo\Debug\TestDemo.pdb

     文件    4342088  2010-03-18 09:15  SystemInfoDemo\public\mfc100.dll

     文件     770384  2010-03-18 09:15  SystemInfoDemo\public\msvcr100.dll

     文件    1731920  2011-11-17 14:41  SystemInfoDemo\public\ntdll.dll

     文件     292352  2012-03-26 14:09  SystemInfoDemo\public\pdh.dll

     文件     117760  2015-05-05 09:23  SystemInfoDemo\public\SystemInfoDemo.exe

     文件    4598784  2015-05-05 09:23  SystemInfoDemo\public\SystemInfoDemo.pdb

     文件    4566016  2015-04-23 11:33  SystemInfoDemo\Release\SystemInfoDemo.pdb

     文件      11264  2015-05-05 09:23  SystemInfoDemo\Release\TestDemo.exe

     文件     568320  2015-05-05 09:23  SystemInfoDemo\Release\TestDemo.pdb

     文件       4608  2015-04-24 14:22  SystemInfoDemo\SystemInfoDemo\CCpuUsagePercent.dll

     文件       3724  2015-04-23 21:02  SystemInfoDemo\SystemInfoDemo\myListCtrl.cpp

     文件        515  2015-04-23 20:50  SystemInfoDemo\SystemInfoDemo\myListCtrl.h

     文件       3146  2015-04-21 22:46  SystemInfoDemo\SystemInfoDemo\ReadMe.txt

............此处省略153个文件信息

评论

共有 条评论