Click to See Complete Forum and Search --> : CPU time on NT/95/98


April 29th, 1999, 09:58 AM
Anybody know how to get CPU time information for an application from within the application? I can get elapsed time from a clock() call, but I really want CPU time.

April 29th, 1999, 12:20 PM
Hi,
Its really easy in case of NT. Use GetProcessTimes() API to get the time spared by CPU for all the threads running in your application. If you want to know the CPU time spent for a thread use GetThreadTimes(). But under 95 there is no reliable mechanism to determine how much time CPU has spent for your thread or process. I don't know about 98. If you couldn't succeed to use the APIs(in case of NT) please get back to me.
Ashley Antony
Ashley.Antony@in.bosch.com
Robert Bosch India Ltd.
Bangalore, India.

Jerry Coffin
April 30th, 1999, 10:07 PM
Under NT, as has already been mentioned, GetThreadTimes and GetProcessTimes work quite nicely. My advice on Windows 95/98 is to simply include a test for running under them, and fail nicely, pointing out that your program will only work correctly under a halfway decent OS.

If you insist on subjecting yourself to it, there's some CPU time data in the performance data in the registry under Windows 95/98, but don't say I didn't warn you...


The universe is a figment of its own imagination.