If this is your first visit, be sure to
check out the
FAQ
by clicking the
link above. You may have to
register
or
Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
I'm trying to use GetProcessTImes() to get some rough idea on actual cpu time (not wall clock) from the windows api.
I read that GetProcessTimes() is quite accurate and gives results back as user time and kernel time both in 100ns interval values.
Now maybe i'm not sure how it works but I was trying to take 2 measurements by calling this function before and after a section of code to get measurement on a certain piece of code. However I get back same values on both calls?
So I have something like:
GetProcessTimes(....param....);
//section of code here
GetProcessTimes(...param...);
But both calls give back the same value? That can't be right or maybe i've misunderstood the purpose of GetProcessTimes() ? Is there another function I should be using instead for my purposes.
Oh btw i'm already using QueryPerformanceCounter() to get wall clock, I was hoping the above which according to MSDN should give actual cpu time...
Well any help and discussion on this is helpful.
Post a small complete example that demonstrates the issue. The "
section of code here
" may just be "too fast" for the API.
well at the moment, I am just creating the base so I don't actually have the "section of code" to measure but for testing I padded it out with several for-loops decrementing from 1billion to 0.
But anyway here is part of the code i have:
FILETIME cpuTime;
FILETIME sysTime;
FILETIME createTime;
FILETIME exitTime;
BOOL c1 = GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &sysTime, &cpuTime);
for(int i=1000000000; i!=0; i--);
for(int i=1000000000; i!=0; i--); //repeat this a few times
FILETIME cpuTime2;
FILETIME sysTime2;
FILETIME createTime2;
FILETIME exitTime2;
BOOL c2 = GetProcessTimes(GetCurrentProcess(), &createTime2, &exitTime2, &sysTime2, &cpuTime2);
EDIT: I think i found my problem, i changed my for-loops to while-loops and now I do get different values, actually I think I might have done something weird with my for-loops in a rush, well i'm happy
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
*
The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.
*
Porting from Android to Windows 8: The Real Story
Do you have an Android application? How hard would it really be to port to Windows 8?
*
Guide to Porting Android Applications to Windows 8
If you've already built for Android, learn what do you really need to know to port your application to Windows Phone 8.
*
HTML5 Development Center
Our portal for articles, videos, and news on HTML5, CSS3, and JavaScript
*
Windows App Gallery
See the Windows 8.x apps we've spotlighted or submit your own app to the gallery!
Advertiser Disclosure:
Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.