How to measure the time taken to run a certain process?
Hi there...
Would like to check with experts of Visual C++ out there..how am I able to get the time taken to run a centain portion of my program.
my current method is
StartClock = clock();
for (i = 0; i<n; i++)
{
x = x + 1; // just an example
}
EndClock = clock();
durationClock = EndClock - StartClock ;
however, it seems that the StartClock and EndClock are the same... probably the function is too fast.
Is there another way to capture the timing?
Thanks.
Joseph
Calculating Energy comsumption using the time taken?
Hi All,
Thanks a lot... it was indeed helpful!
err... GCDEF, what do you mean by profiling?
I'm trying to calculate the Energy consumption for my program on the desktop PC (win2000) running MS VC++ 6.0... based on the time taken...
MY understanding is, since Energy = Power x time, so I first calculate the time taken by my program, multiply by the power consumption per clock by my CPU...
will that give me the Energy comsumed by my program? has anyone tried this before?
Thanks.
Regards,
Joseph
Re: Calculating Energy comsumption using the time taken?
Quote:
Originally posted by tcmjoe
Hi All,
Thanks a lot... it was indeed helpful!
err... GCDEF, what do you mean by profiling?
I'm trying to calculate the Energy consumption for my program on the desktop PC (win2000) running MS VC++ 6.0... based on the time taken...
MY understanding is, since Energy = Power x time, so I first calculate the time taken by my program, multiply by the power consumption per clock by my CPU...
will that give me the Energy comsumed by my program? has anyone tried this before?
Thanks.
Regards,
Joseph
MSDN should provide all the information you need about profileing. It's a tool that tells you how much time your program spends in each function, how often your function is called, etc.
I doubt you can get anything meaningful regarding energy consumption. The CPU is cycling, the hard drive is spinning, the monitor displaying whether your program is running or not. Moving the drive heads may consume a tiny insignificant amount of power, other than that Nothing you could realistically measure I would think. I don't see why consumption would change just because you run a program.