[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Need help with GetPerformanceCounter()



PureBytes Links

Trading Reference Links

Hello,
 
It does not work that way.
The underlying high frequency counter runs all the time since computer start.
What "reset" flag really does is to store last value so next time you read it, it gets subtracted from last value giving you the difference.
If reset is false the last value is set to zero and you get the original number of "clock ticks" since computer start.
 
If you want cumulative value you should rather use, += operator.
 
ElapsedTime += GetPerformanceCounter(True);

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Herman
Sent: Friday, November 09, 2007 12:46 AM
Subject: [amibroker] Need help with GetPerformanceCounter()

Sorry for the cross posting, I can't get an answer anywhere to this problem. Is nobody using the Performance counter???


Perhaps someone here can explain what i am doing wrong. I want the measure elapsed time at various stages of my code. I reset the timer and read it repeatedly I expected to get a cumulative elapsed time value. However this doesn't seem to work for me, I use this testing code:


ElapsedTime = GetPerformanceCounter(True);

_TRACE("#1 Elapsed time: "+NumToStr(ElapsedTime,1.3));

ElapsedTime = GetPerformanceCounter(True);

_TRACE("#2 Elapsed time: "+NumToStr(ElapsedTime,1.3));

ElapsedTime = GetPerformanceCounter(True);

_TRACE("#3 Elapsed time: "+NumToStr(ElapsedTime,1.3));

ElapsedTime = GetPerformanceCounter(False);

_TRACE("#4 Elapsed time: "+NumToStr(ElapsedTime,1.3));

ElapsedTime = GetPerformanceCounter(False);

_TRACE("#5 Elapsed time: "+NumToStr(ElapsedTime,1.3));

ElapsedTime = GetPerformanceCounter(False);

_TRACE("#6 Elapsed time: "+NumToStr(ElapsedTime,1.3));

ElapsedTime = GetPerformanceCounter(False);

_TRACE("#7 Elapsed time: "+NumToStr(ElapsedTime,1.3));

ElapsedTime = GetPerformanceCounter(False);

_TRACE("#8 Elapsed time: "+NumToStr(ElapsedTime,1.3));

_TRACE("#");


and I get this output:


[3176] #1 Elapsed time: 9505696.000

[3176] #2 Elapsed time: 0.142

[3176] #3 Elapsed time: 0.062

[3176] #4 Elapsed time: 0.061

[3176] #5 Elapsed time: 9505696.000

[3176] #6 Elapsed time: 9505696.000

[3176] #7 Elapsed time: 9505696.000

[3176] #8 Elapsed time: 9505696.000

[3176] #


Probably a dumb question, but how come output lines 5-8 do not show cumulative change wrt to the last reset?


many thanks for any help you can give,

herman


For Real-Time Auto-Trading Solutions visit the AmiBroker Users' Knowledge Base (UKB):

http://www.amibroker.org/userkb/

For specific Real-Time Auto-Trading solutions visit:

http://www.amibroker.org/userkb/category/real-time-auto-trading/


Best regards,

Herman


Wednesday, November 7, 2007, 7:10:06 AM, you wrote:



 



===8<===========End of original message text===========



__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___