获取多核CPU使用率,设置CPU亲和性
获取多核CPU使用率,设置CPU亲和性,设置并发线程数和优先级,绑定线程在特点CPU上运行,并测试
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 68571136 2015-06-10 11:00 SystemInfoDemoSystemInfoDemo.sdf
文件 3606 2015-04-28 11:49 SystemInfoDemoSystemInfoDemo.sln
..A..H. 45568 2015-06-10 11:00 SystemInfoDemoSystemInfoDemo.suo
文件 1329 2015-04-24 14:22 SystemInfoDemoCpuUsageCCpuUsagePercent.cs
文件 2330 2015-04-24 14:16 SystemInfoDemoCpuUsageCCpuUsagePercent.csproj
文件 4608 2015-04-24 14:22 SystemInfoDemoCpuUsageinReleaseCCpuUsagePercent.dll
文件 11776 2015-04-24 14:22 SystemInfoDemoCpuUsageinReleaseCCpuUsagePercent.pdb
文件 5615 2015-04-27 09:27 SystemInfoDemoCpuUsageobjDebugDesignTimeResolveAssemblyReferencesInput.cache
文件 390 2015-04-24 14:22 SystemInfoDemoCpuUsageobjReleaseCCpuUsagePercent.csproj.FileListAbsolute.txt
文件 4608 2015-04-24 14:22 SystemInfoDemoCpuUsageobjReleaseCCpuUsagePercent.dll
文件 11776 2015-04-24 14:22 SystemInfoDemoCpuUsageobjReleaseCCpuUsagePercent.pdb
文件 358 2015-04-24 14:15 SystemInfoDemoCpuUsageobjReleaseCpuUsage.csproj.FileListAbsolute.txt
文件 5619 2015-04-27 09:27 SystemInfoDemoCpuUsageobjReleaseDesignTimeResolveAssemblyReferencesInput.cache
文件 1368 2015-04-24 12:35 SystemInfoDemoCpuUsagePropertiesAssemblyInfo.cs
文件 40448 2015-04-28 12:39 SystemInfoDemoDebugTestDemo.exe
文件 393480 2015-04-28 12:39 SystemInfoDemoDebugTestDemo.ilk
文件 633856 2015-04-28 12:39 SystemInfoDemoDebugTestDemo.pdb
文件 4342088 2010-03-18 09:15 SystemInfoDemopublicmfc100.dll
文件 770384 2010-03-18 09:15 SystemInfoDemopublicmsvcr100.dll
文件 1731920 2011-11-17 14:41 SystemInfoDemopublic
tdll.dll
文件 292352 2012-03-26 14:09 SystemInfoDemopublicpdh.dll
文件 117760 2015-05-05 09:23 SystemInfoDemopublicSystemInfoDemo.exe
文件 4598784 2015-05-05 09:23 SystemInfoDemopublicSystemInfoDemo.pdb
文件 4566016 2015-04-23 11:33 SystemInfoDemoReleaseSystemInfoDemo.pdb
文件 11264 2015-05-05 09:23 SystemInfoDemoReleaseTestDemo.exe
文件 568320 2015-05-05 09:23 SystemInfoDemoReleaseTestDemo.pdb
文件 4608 2015-04-24 14:22 SystemInfoDemoSystemInfoDemoCCpuUsagePercent.dll
文件 3724 2015-04-23 21:02 SystemInfoDemoSystemInfoDemomyListCtrl.cpp
文件 515 2015-04-23 20:50 SystemInfoDemoSystemInfoDemomyListCtrl.h
文件 3146 2015-04-21 22:46 SystemInfoDemoSystemInfoDemoReadMe.txt
............此处省略153个文件信息
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 SystemInfoDemoSystemInfoDemo.sdf
文件 3606 2015-04-28 11:49 SystemInfoDemoSystemInfoDemo.sln
..A..H. 45568 2015-06-10 11:00 SystemInfoDemoSystemInfoDemo.suo
文件 1329 2015-04-24 14:22 SystemInfoDemoCpuUsageCCpuUsagePercent.cs
文件 2330 2015-04-24 14:16 SystemInfoDemoCpuUsageCCpuUsagePercent.csproj
文件 4608 2015-04-24 14:22 SystemInfoDemoCpuUsageinReleaseCCpuUsagePercent.dll
文件 11776 2015-04-24 14:22 SystemInfoDemoCpuUsageinReleaseCCpuUsagePercent.pdb
文件 5615 2015-04-27 09:27 SystemInfoDemoCpuUsageobjDebugDesignTimeResolveAssemblyReferencesInput.cache
文件 390 2015-04-24 14:22 SystemInfoDemoCpuUsageobjReleaseCCpuUsagePercent.csproj.FileListAbsolute.txt
文件 4608 2015-04-24 14:22 SystemInfoDemoCpuUsageobjReleaseCCpuUsagePercent.dll
文件 11776 2015-04-24 14:22 SystemInfoDemoCpuUsageobjReleaseCCpuUsagePercent.pdb
文件 358 2015-04-24 14:15 SystemInfoDemoCpuUsageobjReleaseCpuUsage.csproj.FileListAbsolute.txt
文件 5619 2015-04-27 09:27 SystemInfoDemoCpuUsageobjReleaseDesignTimeResolveAssemblyReferencesInput.cache
文件 1368 2015-04-24 12:35 SystemInfoDemoCpuUsagePropertiesAssemblyInfo.cs
文件 40448 2015-04-28 12:39 SystemInfoDemoDebugTestDemo.exe
文件 393480 2015-04-28 12:39 SystemInfoDemoDebugTestDemo.ilk
文件 633856 2015-04-28 12:39 SystemInfoDemoDebugTestDemo.pdb
文件 4342088 2010-03-18 09:15 SystemInfoDemopublicmfc100.dll
文件 770384 2010-03-18 09:15 SystemInfoDemopublicmsvcr100.dll
文件 1731920 2011-11-17 14:41 SystemInfoDemopublic
tdll.dll
文件 292352 2012-03-26 14:09 SystemInfoDemopublicpdh.dll
文件 117760 2015-05-05 09:23 SystemInfoDemopublicSystemInfoDemo.exe
文件 4598784 2015-05-05 09:23 SystemInfoDemopublicSystemInfoDemo.pdb
文件 4566016 2015-04-23 11:33 SystemInfoDemoReleaseSystemInfoDemo.pdb
文件 11264 2015-05-05 09:23 SystemInfoDemoReleaseTestDemo.exe
文件 568320 2015-05-05 09:23 SystemInfoDemoReleaseTestDemo.pdb
文件 4608 2015-04-24 14:22 SystemInfoDemoSystemInfoDemoCCpuUsagePercent.dll
文件 3724 2015-04-23 21:02 SystemInfoDemoSystemInfoDemomyListCtrl.cpp
文件 515 2015-04-23 20:50 SystemInfoDemoSystemInfoDemomyListCtrl.h
文件 3146 2015-04-21 22:46 SystemInfoDemoSystemInfoDemoReadMe.txt
............此处省略153个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)