Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Plastico
20
Years of Service
User Offline
Joined: 3rd May 2004
Location:
Posted: 16th Jul 2004 05:56
erm, when I want to time my code, how do I get the timer() to work?

what I mean is, the manual says this
Quote: "Return Integer=timer()"


what is the return integer, or better yet can someone show me an example?

Im trying to do this:

Timer=1000
paste sprite x,x,x
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 16th Jul 2004 06:41
timer() is a function that returns the milliseconds since midnight/or since last boot. Anyway

iTmr as integer
iTmr=Timer()


DBP_NETLIB_v1.4.3 - 65 FREE Functions * Click Logo
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 16th Jul 2004 06:49
Yeah, timer() reads the internal CPU clock, returning a number that is rather large but constantly being incremented as the system operates. Thus if you wanted to test how long your loop your took to operate, you'd read timer() at the beginning into a variable, then read it again at the end, and subtract the two. ie;

do
time_start=timer()

(rest of code)

time_stop=timer()
run_time=time_stop-time_start
print"run time was=",run_time
loop

The other use is to slow down programs, be creating a small loop to wait X amount of time no matter how fast the loop ran, as in the difference between machines;

time1=timer()
do

(rest of code)

loop1:
time2=timer()
if time2 < time1+100 then goto loop1
time1=time2
loop

Which waits for 1/10 of a second for each pass through the code.

Good Luck!
S.

Any truly great code should be indisguishable from magic.
Plastico
20
Years of Service
User Offline
Joined: 3rd May 2004
Location:
Posted: 16th Jul 2004 07:35
thanks!

Login to post a reply

Server time is: 2024-09-22 16:25:38
Your offset time is: 2024-09-22 16:25:38