Click here to Skip to main content
15,121,624 members
Articles / Mobile Apps
Tip/Trick
Posted 2 Dec 2010

Tagged as

Stats

17.1K views
5 bookmarked

Mobile processor usage

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

C++
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%

Enjoy!

License

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

Share

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
http://social.msdn.microsoft.com/profile/paulh79

Comments and Discussions

 
GeneralMy vote of 4 Pin
hjgode22-Nov-12 21:06
Memberhjgode22-Nov-12 21:06 

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

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