本文介绍了如何读取GPU负载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个程序,该程序监视计算机的各种资源,例如CPU使用率等.我也想监视GPU使用情况(GPU负载,而不是温度).
I am writing a program that monitors various resources of the computer, such as CPU usage and so on. I want to monitor GPU usage (the GPU load, not temperature) as well.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using DannyGeneral;
namespace CpuUsage
{
public partial class Form1 : Form
{
private bool processEnded;
private Process[] processList;
private string timeStarted;
private string timeEnded;
private List<float> processValues;
private bool alreadyRun;
private DateTime dt;
private DateTime dt1;
private PerformanceCounter theCPUCounter;
private PerformanceCounter theMemCounter;
private PerformanceCounter specProcessCPUCounter;
private float cpuUsage;
private float memUsage;
private List<float> Values;
public Form1()
{
InitializeComponent();
processEnded = false;
processList = Process.GetProcesses();
for (int i = 0; i < processList.Count(); i++)
{
listView1.Items.Add(processList[i].ProcessName);
}
processValues = new List<float>();
alreadyRun = false;
dt = DateTime.Now;
Values = new List<float>();
theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
theMemCounter = new PerformanceCounter("Memory", "Available MBytes");
specProcessCPUCounter = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName);
Logger.Write("The Program Started At *** " + DateTime.Now.ToShortTimeString());
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
memUsage = theMemCounter.NextValue();
label1.Text = memUsage.ToString();
Logger.Write("Memory Usage " + memUsage.ToString());
cpuUsage = this.theCPUCounter.NextValue();
label2.Text = cpuUsage.ToString();
Logger.Write("Cpu Usage " + this.cpuUsage.ToString());
Values.Add(cpuUsage);
isProcessRunning();
if (alreadyRun == true)
{
processValues.Add(cpuUsage);
}
}
推荐答案
video card's own CPU
被称为GPU
.
查找与此相关的性能计数器或video
(使用Start->Run->PerfMon
或在Start
菜单的搜索框中键入PerfMon
;右键单击图形并选择Add Counter...
).
Look for performance counters related to that or video
(using Start->Run->PerfMon
or typing PerfMon
in the Start
menu's search box; right-click on the graph and choose Add Counter...
).
如果您的视频卡制造商未提供GPU的性能计数器,那么您就没有了.
If your video card maker didn't provide any performance counters for the GPU, there aren't any for you to get.
这篇关于如何读取GPU负载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!