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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
benny1564
Novice


Joined: 22 Jun 2004
Posts: 48

PostPosted: Sat Jul 23, 2005 8:40 am   

Measure the time between two triggered lines?
 
Is there any way to measure the time between two triggered lines? In milliseconds?
And can I use milliseconds with #alarm?
_________________
Reply with quote
Goldenchild
Newbie


Joined: 15 Jun 2005
Posts: 4

PostPosted: Sat Jul 23, 2005 11:53 am   
 
A friend gave this to me, hope it helps.....



Code:
#CLASS {Stopwatch}
#ALIAS viewstats {totalval=0;#FORALL @timerec {#ADD totalval %float( %i)};#ECHO %ansi( 12) Stopwatch Statistics;#ECHO Replication: %numitems( @timerec);#ECHO Mean Time: %leftback( %eval( @totalval/%numitems( @timerec)/1000.0), %eval( %pos( ".", %eval( @totalval/%numitems( @timerec)/1000.0))+9)) secs;#ECHO Mean Time "(1 dec place)": %leftback( %eval( @totalval/%numitems( @timerec)/1000.0), %eval( %pos( ".", %eval( @totalval/%numitems( @timerec)/1000.0))+11)) secs;#ECHO Min Time: %min( %replace( @timerec, "|", ",")) secs, Max Time: %max( %replace( @timerec, "|", ",")) secs}
#ALIAS stopwatchon {#ECHO Stopwatch ON;#STATE stopwatch 1}
#ALIAS stopwatchoff {#STATE stopwatch 0;#ECHO Stopwatch OFF}
#ALIAS setstart {starttrig={%-1};timerec=%null}
#ALIAS setstop {stoptrig={%-1}}
#VAR starttrig {This is where your first triggered line goes.}
#VAR timerec {}
#VAR stoptrig {This is where your second line goes.}
#VAR totalval {}
#VAR starttime {}
#CLASS 0
Reply with quote
Full Throttle
Wanderer


Joined: 07 Dec 2004
Posts: 65

PostPosted: Sat Jul 23, 2005 8:48 pm   
 
Using the secs function to measure milliseconds between triggers:

Code:
#var secs {0} {0}
#trigger {First Pattern} {
#var secs %secs}
#trigger {Second Pattern} {
#if (@secs > 0) {#echo %eval(%secs-@secs) milliseconds}
#var secs 0}


The secs function is the number of milliseconds since midnight.

Using milliseconds with #alarm:

Code:
#alias alarm {#execute %concat("#alarm +",%eval(%float(%1)/1000)," {...}")}


For example, the alias "alarm 3500" would execute the command string in 3.5 seconds.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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