![]() |
|
#1
|
|||
|
|||
|
According to Fitzbean, GetTickCount is not accurate.
[link]http://www.delphipages.com/threads/thread.cfm?ID=163424&G=163306[/link] He refers to MMSystem.timeGetTime which I can't find in Delphi 4 or Delphi 7 help, though I do find GetTime in Delphi 7 help. It's for use in place of Time on a Linux system. There's no mention of improved accuracy. I thought I remembered reading on this forum (but couldn't find it) that the difference obtained by subtracting two GetTickCounts was more accurate than that obtained by comparing two times from calling the NOW function. What is the best way to make micro small time measurements like for measuring execution time? I don't find that help files address the accuracy on any. jdg.ho I love this forum. Your generosity is wonderful. |
|
#2
|
|||
|
|||
|
This is a Copy/Paste of an article that I found on the web which talks about highly accurate way to measure the execution time:
.................................................. ......... Question/Problem/Abstract: I am optimizing a function and want to know the difference in execution time before and after optimization in microseconds!! Answer: put this in the var section of your function or procedure Ctr1, Ctr2, Freq,Overhead: int64; R: extended; and put this at the beginnig of the function or more generally speaking at the beginning of the code you want to optimize. [DELPHI] QueryPerformanceFrequency(Freq); QueryPerformanceCounter(Ctr1); QueryPerformanceCounter(Ctr2); Overhead := Ctr2 - Ctr1; // determine API overhead QueryPerformanceCounter(Ctr1); put this at the end of the code QueryPerformanceCounter(Ctr2); R := ((Ctr2 - Ctr1) - Overhead) / Freq; showmessage( 'The function took ' + FloatToStr(R) + ' seconds'); [/DELPHI] important note: remember that the execution time of any function under most operating systems is affected also by services and programs running in the backgroud. So it is adviced that you keep your desktop state constant while optimizing. This way you will get execution time in microsecond precision. This is translated to delphi from a vb article at MSDN. //This is the end of the article. .................................................. ......... Also see this [link]http://www.swissdelphicenter.ch/en/showcode.php?id=498[/link] Regards, Abdulaziz Jasser |
|
#3
|
|||
|
|||
|
Thanks Jasser,
That's helpful. I'll let question remain open for a while for additional comment, although there doesn't seem to be much interest. jdg.ho I love this forum. Your generosity is wonderful. |
|
#4
|
|||
|
|||
|
jdg,
Still wanna keep this open ![]() Regards, Abdulaziz Jasser |
|
#5
|
|||
|
|||
|
I was looking for some comments on GetTickCount vs GetTime vs Now. Not really another way to do the same thing. But, what the hey, I'll give you the point for your time. Thanks.
jdg.ho I love this forum. Your generosity is wonderful. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|