-
December 30th, 2011, 11:44 AM
#1
How to accurately time process execution
Hi, is it possible to more accurately determine the performance of my code as opposed to GetTickCount or higher resolutions versions such as QueryPerformanceCounter?
The problem with GetTickCount is that it only measures the absolute time my code takes to execute which can be can be distorted by background processing and is therefore not a completely accurate measure i.e. it serves as a guide only. Higher resolution timers don't fix this eg QueryPerformanceCounter. So how can I determine the CPU time that my process used to execute (independently to all other processes running in the background)?
-
December 30th, 2011, 01:11 PM
#2
Re: How to accurately time process execution
Take a look at GetProcessTimes.
-
January 1st, 2012, 10:20 AM
#3
Re: How to accurately time process execution
Hi ovidiucucu
I tried using it, however, it seems to return exactly the same numbers as gettickcount each and every call, i.e., it is unable to return the cpu time share used by my process.
If there is no way to do this, perhaps it is because Windows is a more commercially focused OS and not designed for serious performance testing, issues and implementations?
-
January 1st, 2012, 12:14 PM
#4
Re: How to accurately time process execution
starting from Vista, there's also the QueryProcessCycleTime API; anyway, I think you should be able of retriving an equivalent estimate via the API suggested by ovidiucucu as well ...
that said
Originally Posted by Witis
perhaps it is because Windows is a more commercially focused OS and not designed for serious performance testing, issues and implementations?
this has nothing to do with being "commercial" or not ( whatever it means ), it's just that windows is not a real time os, hence it gives no strict guarantees on the timing of side-effects of your code, making such "true-cpu-time" measurements simply pointless. BTW, the exact number of cpu cycles used by a thread can depend on an amount of difficult to track factors, why are you interested in such a measurement ? Provided you develop for general purpose OSes, I don't think this would qualify as "serius performance testing" ...
-
January 4th, 2012, 05:50 PM
#5
Re: How to accurately time process execution
Originally Posted by Witis
Hi ovidiucucu
I tried using it, however, it seems to return exactly the same numbers as gettickcount each and every call, i.e., it is unable to return the cpu time share used by my process.
“Calendar” time (like GetTickCount returns) will differ from thread time only if your process was unable to get all the CPU time it needed.
Was your system overloaded?
With modern equipment, your process might even get a full core for exclusive use...
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|