Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
adamandkate
Wanderer


Joined: 14 Oct 2009
Posts: 57

PostPosted: Wed Apr 07, 2010 11:13 pm   

making a milliseccond timer. any ideas where to start?
 
hey. im trying to make a timer in millisecconds.. first alias set it to zero and start the timer. secconds alias that halts the timer and display how many secconds and milisecconds it took. i was going to use #alarm but that cant go lower then 0.501

thanks
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Apr 08, 2010 12:43 am   
 
You will have to do this "the old-fashioned way" with a continous loop and the #WAIT command.

Code:
#function Count_Milliseconds() {
  #until (@new_second) {
    #wait 100
    #add timer.milliseconds 1
    #if (@timer.milliseconds < 1000) {#add timer.seconds 1} {
      timer.milliseconds = 0
      new_second = 1
    }
  }
}


From there, a 1-second alarm will suffice.

Code:
#alarm {*1} {
  #if (@new_second) {
    new_second = 0
    #call @Count_Milliseconds()
  }
}


The above is VERY rough and completely untested. In addition, it uses a thread-spawning command called #WAIT so there might be timing/thread-synchronization issues to be worked out.
_________________
EDIT: I didn't like my old signature
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Thu Apr 08, 2010 12:47 am   
 
You could also just save the value of %secs when you start and then compare %secs when you stop the timer with the saved value. The %secs function returns time with millisecond precision.
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Thu Apr 08, 2010 12:42 pm   
 
in some alias that does a lot of processing...

Code:

$timer_start = %eval( %secs)
all your code here todo whatever
#SHOW {Process took: %eval( %secs - $timer_start)ms}
Reply with quote
adamandkate
Wanderer


Joined: 14 Oct 2009
Posts: 57

PostPosted: Sun Apr 11, 2010 6:09 am   
 
thats great thanks guys. i went with zuggs option as it was the simplist i think. working well so far
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net