Re: How to time the execution of a method?




"Maarten Wiltink"

This solves a different problem. You measure a thousand times,
then average all the individual measurements. If the resolution
of GetTickCount is not sufficient to measure the time taken by
calling x, that won't help. The average of a thousand zeroes is
still zero.

tot/1000 is not the average, but to get seconds from milliseconds.
But you're right: it is better and simpler to call GetTickCount only
twice:

t := GetTickCount;
for i := 1 to 1000 do x;
tot := GetTickCount - t;

This way we're timing the /for/ too, but it's still ok to compare
different methods.


.



Relevant Pages

  • Re: Help! Problem on CPU usage and performance tuning.
    ... > GetTickCountfunction just as comparison with GetThreadTimes(). ... This resolution is stored in "nt! ... So you see that the resolution is better than with "GetTickCount" but it ... > test time is a way. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Accurate time measurement
    ... "Multiple statements execute before either ... GetTickCount or timeGetTime record a change" and adding, ... increase the resolution of both GetTickCount and timeGetTime using ...
    (microsoft.public.vb.general.discussion)
  • Re: Timer accuracy.
    ... >> resolution timer and is more accurate than GetTickCount ... >> Private Declare Function timeGetTime _ ... >You have to be a bit careful about the timeGetTime function Jerry. ...
    (microsoft.public.vb.general.discussion)
  • Re: high resolution elapsed time???
    ... resolution. ... Private Declare Function GetTickCount Lib "kernel32" As Long ... '// from the last time this routine was called. ... Dim THIS_TIME As Long ...
    (microsoft.public.vc.language)
  • RE: Sleep() is not accurate on XP P4 2.8G
    ... In XP Pro I have found Sleep() has a 15ms resolution as the default and ... GetTickCount() has 1ms resolution by default. ...
    (microsoft.public.win32.programmer.networks)