Windows CPU Memory Network Performance Statistics Article 3 CPU multi-core CPU core usage C #

Source: Internet
Author: User

This article supporting procedures: http://download.csdn.net/detail/morewindows/5160822

Reprinted please indicate the source, original address: http://blog.csdn.net/morewindows/article/details/8678382

Welcome to Weibo: http://weibo.com/MoreWindows

 

Windows CPU Memory Network Performance Statistics Article 3 CPU multi-core CPU core usage C #

Http://blog.csdn.net/morewindows/article/details/8678382

 

In the previous section, CPU memory network performance statistics for Windows system, article 2 CPU overall usage describes how to obtain the overall CPU usage in Windows XP and Windows 7 systems. Currently, most CPUs are multi-core CPUs, therefore, this article describes how to obtain the usage of each core of a multi-core CPU.

Windows system CPU Memory Network Performance Statistics blog directory:

1. Windows system CPU Memory Network Performance Statistics Article 1 memory

Http://blog.csdn.net/morewindows/article/details/8459219

2. Windows system CPU Memory Network Performance Statistics Article 2 Overall CPU usage

Http://blog.csdn.net/morewindows/article/details/8678359

3. Windows system CPU Memory Network Performance Statistics Article 3 CPU multi-core CPU core usage C #

Http://blog.csdn.net/morewindows/article/details/8678382

4. Windows system CPU Memory Network Performance Statistics Article 4 CPU multi-core CPU core usage C ++

Http://blog.csdn.net/morewindows/article/details/8678396

 

It is very convenient to use C # To obtain the usage of each core of a multi-core CPU. In just a few lines, and the program can run normally in Windows XP and Windows 7 systems. The following code is provided first.

// Windows system CPU Memory Network Performance Statistics third article CPU multi-core CPU core usage C # // tested, can be used in WINXP and win7 // http://blog.csdn.net/morewindows/article/details/8678382using system; using system. diagnostics; using system. threading; namespace consoleapplication1 {class program {static void main (string [] ARGs) {console. writeline ("Windows system CPU Memory Network Performance Statistics Article 3 CPU multi-core CPU core usage C #"); console. writeline ("-http://blog.csdn.net/morewindows/article/details/8678382-"); console. writeline ("-- by morewindows (http://blog.csdn.net/MoreWindows) -- \ n"); performancecounter [] counters = new performancecounter [system. environment. processorcount]; for (INT I = 0; I <counters. length; I ++) {counters [I] = new performancecounter ("processor", "% processor time", I. tostring ();} while (true) {for (INT I = 0; I <counters. length; I ++) {float F = counters [I]. nextvalue (); console. write ("CPU-{0 }:{ 1: F }%", I + 1, F);} console. writeline (); thread. sleep (1000 );}}}}

The Code shows that the performancecounter class in system. Diagnostics is used. This class is powerful. You can refer to msdn for a detailed explanation.

 

In WINXP system running results are as follows (this article supporting program: http://download.csdn.net/detail/morewindows/5160822 ):

 

In win7 system running results are as follows (this article supporting program: http://download.csdn.net/detail/morewindows/5160822 ):

 

From this article "Windows system CPU Memory Network Performance Statistics third article CPU multi-core CPU core usage C #" (http://blog.csdn.net/morewindows/article/details/8678382) can be seen that C # is undoubtedly a very convenient language, for C/C ++ programmers, understanding C # is very helpful.

The next Windows system CPU Memory Network Performance Statistics Fourth Article CPU multi-core CPU core usage of C ++ (http://blog.csdn.net/morewindows/article/details/8678396) this section describes how to use C ++ code to reference the DLL written in C # To obtain the CPU usage of multiple cores in C ++.

 

This article supporting procedures: http://download.csdn.net/detail/morewindows/5160822

Reprinted please indicate the source, original address: http://blog.csdn.net/morewindows/article/details/8678382

Welcome to Weibo: http://weibo.com/MoreWindows

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.