https://www.cnblogs.com/Chary/p/7771365.html

http://www.cnblogs.com/zl1991/p/4679461.html

要关注几个类 PerformanceCounter 用来针对cpu  ;ComputerInfo 用来针对内存

  1. using Microsoft.VisualBasic.Devices;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace CpuAndMemory
  10. {
  11. class Program
  12. {
  13. //PerformanceCounter 性能计数器
  14. public static PerformanceCounter cpu;
  15.  
  16. //来自程序集 Microsoft.VisualBasic.dll 手动引用
  17. public static ComputerInfo cInfo;
  18. static void Main(string[] args)
  19. {
  20. cpu = new PerformanceCounter("Processor", "% Processor Time", "_Total");
  21.  
  22. //---------------内存相关---------------
  23. cInfo = new ComputerInfo();
  24. Console.WriteLine("当前计算机的总内存大小为"+cInfo.TotalPhysicalMemory//+"G");
  25. Console.WriteLine("当前计算机的虚拟内存大小为:"+cInfo.TotalVirtualMemory / / + "G");
  26. Console.WriteLine("当前计算机的虚拟内存大小为:" + cInfo.TotalVirtualMemory);
  27. Console.WriteLine("当前计算机的可用物理内存大小为:" + cInfo.AvailablePhysicalMemory);
  28. Console.WriteLine("当前计算机的可用虚拟内存大小为:" + cInfo.AvailableVirtualMemory);
  29. //---------------内存相关---------------
  30. Console.ReadKey();
  31. }
  32. }
  33. }

获取当前电脑的cpu使用率、内存使用率的更多相关文章

  1. .NET获取当前程序所在电脑的CPU和内存使用率

    using System; using System.Diagnostics; using System.Text; using System.Runtime.InteropServices; nam ...

  2. C#获取CPU和内存使用率

    获取内存使用率 方式1: using System; using System.Runtime.InteropServices; namespace ConsoleApp1 { public clas ...

  3. C#获取特定进程CPU和内存使用率

    首先是获取特定进程对象,可以使用Process.GetProcesses()方法来获取系统中运行的所有进程,或者使用Process.GetCurrentProcess()方法来获取当前程序所对应的进程 ...

  4. Python获取CPU、内存使用率以及网络使用状态代码

    Python获取CPU.内存使用率以及网络使用状态代码_python_脚本之家 http://www.jb51.net/article/134714.htm

  5. Linux下使用java获取cpu、内存使用率

    原文地址:http://www.voidcn.com/article/p-yehrvmep-uo.html 思路如下:Linux系统中可以用top命令查看进程使用CPU和内存情况,通过Runtime类 ...

  6. 转:ZABBIX监控H3C设备的CPU和内存使用率

      由于最近监控的H3C路由器经常出现死机现象,SNMP获取不到数据,后面检查发现是CPU使用率过高,直接导致无法处理SNMP请求,所以需求来了,怎样通过SNMP监控H3C路由器的CPU和内存使用率? ...

  7. Ubuntu 16.04 标题栏实时显示上下行网速、CPU及内存使用率--indicator-sysmonitor

    ---------------------------------------------------------------------------- 原文地址:http://blog.csdn.N ...

  8. Ubuntu 16.04 标题栏实时显示上下行网速、CPU及内存使用率

    有时感觉网络失去响应,就通过Ubuntu 14.04自带的系统监视器程序来查看当前网速,但是这样很不方便,遂打算让网速显示在标题栏,那样就随时可直观的看到.一番搜索尝试后,成功实现!同时也实现了CPU ...

  9. PC-改变电脑的CPU,内存,硬盘大小!

    如何修改CPU频率及内存容量和硬盘大小 改变电脑的CPU,内存,硬盘大小!--------------------------------------------------------------- ...

  10. .NET/C# 如何获取当前进程的 CPU 和内存占用?如何获取全局 CPU 和内存占用?

    原文:.NET/C# 如何获取当前进程的 CPU 和内存占用?如何获取全局 CPU 和内存占用? 都知道可以在任务管理器中查看进程的 CPU 和内存占用,那么如何通过 .NET 编写代码的方式来获取到 ...

随机推荐

  1. Learn from Architects of Buildings

     Learn from Architects of Buildings Keith Braithwaite Architecture is a social act and the material ...

  2. [RxJS] Reusable multicasting with Subject factories

    The way we use publish() (or multicast with an RxJS Subject) makes the shared Observable not reusabl ...

  3. u8和unsigned char的区别

  4. [D3] Convert Input Data to Output Values with Linear Scales in D3

    Mapping abstract values to visual representations is what data visualization is all about, and that’ ...

  5. Android面试准备 第二天 第五例 数据存储

    參考:http://blog.csdn.net/lmj623565791/article/details/24015867 5.Activity用SharedPreferences保存数据,大小有木有 ...

  6. 【solr专题之四】在Tomcat 中部署Solr4.x 分类: H_HISTORY 2014-07-17 16:08 1286人阅读 评论(0) 收藏

    1.安装Tomcat (1)下载并解压至/opt/tomcat中 # cd /opt/jediael # tar -zxvf apache-tomcat-7.0.54.tar.gz # mv apac ...

  7. HttpServletRequest方法

    HttpServletRequest HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,开发人员通过这个对象 ...

  8. [Angular] NgRx/effect, why to use it?

    See the current implementaion of code, we have a smart component, and inside the smart component we ...

  9. 忙里偷闲( ˇˍˇ )闲里偷学【C语言篇】——(4)for == while ?

    一.for和while等价替换 int i = 1; for (i; i<=100; i++){ sum = sum + 1; } int i = 1; while(i<=100){ su ...

  10. [Codevs 1107][NOIP 1107]等效表达

    主题连接:http://codevs.cn/problem/1107/ 一道非常奇妙的题目. 对于算术表达式一类的问题,能够採用编译原理里的后缀表达式的方式来做.详细做法是分别维护两个栈,一个栈里保存 ...