Click here to Skip to main content
15,896,526 members
Articles / Programming Languages / C++

Get CPU Usage with GetSystemTimes

Rate me:
Please Sign up or sign in to vote.
4.27/5 (26 votes)
20 Dec 2004Public Domain1 min read 350.1K   7.4K   59  
How to get CPU usage with GetSystemTimes
In this article, you will find a solution for getting CPU usage with the help of GetSystemTimes.
// GetCPU.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "cpu.h"

int _tmain(int argc, _TCHAR* argv[])
{
	CPU cpu;
    int sys;
    int process;
    TKTime upTime;

    for( ;; )
    {
        Sleep( 200 );
        process = cpu.GetUsage( &sys, &upTime );
        wprintf( _T("Process : %d\tSystem  : %d\n"), process, sys );
    }

    return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Web Developer
United Kingdom United Kingdom
http://dev.jesover.net

Comments and Discussions