Several methods can be used to accelerate programs that use mainly the expression evaluator. The first one is to use quick access variables. It is also possible to send the instructions directly to the expression evaluator. This can be done with the instruction
[
All subsequent instructions will be sent directly to the expression evaluator until the instruction
]
is reached. Of course such sections of programs cannot contain ordinary commands or call programs. If the instruction
[0
is given instead of [, the evaluation of object terms (cf. 7.4) is disabled, and this increases again the speed of this program part. If the instruction
[1
is given, some other optimizations are done.
For instance consider the following program that can be found in the file test/com/test3.cmd
:prog1 2 0 -1 ; ; ; time 0 a=0 b=0 c=0 d=0 e=0 f=0 g=0 h=0 i=0 j=0 k=0 l=0 m=0 n=0 o=0 p=0 do z 1 #1 do x 1 1000 a=a+0.000001 b=b+0.000001 c=c+0.000001 d=d+0.000001 e=e+0.000001 f=f+0.000001 g=g+0.000001 h=h+0.000001 i=i+a+b j=j+b+c k=a+b+d+i+h l=i+k+d m=m+e+f n=m+k+g o=o+e+h+n p=p+e enddo enddo echof a undef * echo \n ; ;
It contains an inner loop that performs 1000 times 16 computations involving 16 variables. So prog1 n will make n times this inner loop. In the file test3.cmd are seven other versions of this program, called prog2 to prog8.
prog2 uses the instruction [
prog3 uses the instruction [0
prog4 uses the instruction [1
prog5 is similar to prog1, with quick access variables.
prog6 is similar to prog2, with quick access variables.
prog7 is similar to prog3, with quick access variables.
prog8 is similar to prog4, with quick access variables.
:prog8 2 0 -1 ; ; ; time 0 [1 @a=0 @b=0 @c=0 @d=0 @e=0 @f=0 @g=0 @h=0 @i=0 @j=0 @k=0 @l=0 @m=0 @n=0 @o=0 @p=0 do @z 1 #1 do @x 1 1000 @a=@a+0.000001 @b=@b+0.000001 @c=@c+0.000001 @d=@d+0.000001 @e=@e+0.000001 @f=@f+0.000001 @g=@g+0.000001 @h=@h+0.000001 @i=@i+@a+@b @j=@j+@b+@c @k=@a+@b+@d+@i+@h @l=@i+@k+@d @m=@m+@e+@f @n=@m+@k+@g @o=@o+@e+@h+@n @p=@p+@e enddo enddo ] echof @a echo \n ; ;
There is also a program, called tout_3 that executes prog1 to prog8, and prints the execution time of each program. On my PentiumPro 180Mhz the execution of tout_3 100 gives the following :
------------------> prog1 100 0.1 ------------------> time Time : 78 s ------------------> prog2 100 0.1 ------------------> time Time : 62 s ------------------> prog3 100 0.1 ------------------> time Time : 53 s ------------------> prog4 100 0.1 ------------------> time Time : 40 s ------------------> prog5 100 0.1 ------------------> time Time : 63 s ------------------> prog6 100 0.1 ------------------> time Time : 49 s ------------------> prog7 100 0.1 ------------------> time Time : 38 s ------------------> prog8 100 0.1 ------------------> time Time : 26 s
In this example the most optimized program runs 3 times faster than prog1.