[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.3.1.10 Clear or Output Timer (#Y)

The Clear or Output Timer command allows the programmer to manually clear Timer 1 or 2, to check the Timer's accumulated value, or to output the current value of Timer 1 or 2 to the output file, preceded by a 'T'. This command is useful for timing operations using Timer 2, to see if there is some unaccounted-for overhead in Cogsys commands.

Name:
Clear or Output Timer
Class:
Control
Code:
#Y
Syntax:
#Y[Timer number,Clear or Output or Check]
System:
Clears or outputs the desired timer. Timer number is 1 or 2. If the second argument is zero, then clear the timer. If the second argument is one, then output the timer value. If the second argument is 2, then put the timer's value in V5. When the value is outputted, the timer value is also available for testlist access as V5 (see example below).

History:
Introduced in Cogsys 4.

Test Files:
NUMY_T01.IN: Tests basic operation

 
@C
Testing the "timer" function \#Y#W2000
Starting the timing now, and waiting 5 seconds.
Press any key after the 'x' appears...

#Y[2,0]#W5000x#R$AV20=V5#Y[2,2]$AV21=V5

You waited $SV20 milliseconds to press a key.
The Background Timer timed $SV21 milliseconds, including
the 5000-millisecond "Hard" wait.
$MV22=V21-V20 $MV22=V22-5000
There were $SV22 milliseconds of "overhead".#W2000

Now we will test how long it takes to put 1000 characters
out to the screen...#W2000

Press any key to continue.#R@C#Y[2,0]
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
1234567890123456789012345678901234567890123456789
#Y[2,1]$AV22=V5
$MV23=1000/V22
It took $SV22 milliseconds to print 1000 characters
to the screen.  This is $SV23 characters per millisecond.

Press any key to exit#R

Example:

input
 
#Y[2,0]#W1000#Y[2,1]
A one second wait took $SV5 milliseconds
cogsys
Clears timer 2, waits 1000 milliseconds, then writes out "One second wait took 1000 milliseconds". If the overhead in the #W command took one millisecond or longer, this would be reflected in an output value larger than "1000 milliseconds".


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on November, 24 2008 using texi2html