|
adamandkate Wanderer
Joined: 14 Oct 2009 Posts: 57
|
Posted: 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 |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: 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.
|
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: 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}
|
|
|
|
|
adamandkate Wanderer
Joined: 14 Oct 2009 Posts: 57
|
Posted: 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
|
|
|
|
|
|