Click here to Skip to main content
11,645,087 members (72,933 online)
Click here to Skip to main content

Tagged as

Mobile processor usage

, 21 Feb 2011 CPOL 10.2K 5
Rate this:
Please Sign up or sign in to vote.
Are you curious how busy your Windows Mobile device's processor is? Try this chunk of code using GetIdleTime().

DWORD start = ::GetTickCount();
DWORD idle_start = ::GetIdleTime();
Sleep( 1000 );
DWORD stop = ::GetTickCount();
DWORD idle_end = ::GetIdleTime();
float percent_used = 100 - ( 100.0f * ( idle_end - idle_start ) ) / static_cast< float >( stop - start );
NKDbgPrintfW( L"Processor usage: %d%%\r\n", ( int )percent_used );

For me, this prints:
Processor usage: 3%



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Paul Heil
Software Developer (Senior) An engineering firm in Cedar Rapids, Iowa
United States United States
I'm also on the MSDN forums

You may also be interested in...

Comments and Discussions

GeneralMy vote of 4 Pin
hjgode22-Nov-12 20:06
memberhjgode22-Nov-12 20:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150731.1 | Last Updated 21 Feb 2011
Article Copyright 2010 by Paul Heil
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid