Make your own free website on Tripod.com

 

 

UBASIC Speed Hints

Loops
A loop containing 
    if Inbyte<>I then ....
Took 219 ms

where a loop containing
    If Inbyte=I then....
Took 31 ms, or about 7 times faster.

Subroutines
If the sub is small, your program may run significantly faster if the code is in the main body rather using the subroutine, especially if sub is called many times.

 

On a 486DX/4 75 MHz:

310    Inbyte%=bitxor(bitor(bitand(inp(957),240),bitand(inp(958),15)),139)

Runs in 65% of the time it takes this:

310    B1=bitand(inp(base+1),240)
320    B2=bitand(inp(base+1),15)
330    Inbyte=bitor(B1,B2)

Using Hex instead of decimal values slowed it down slightly.

BUT,  Out base%,0   tested 4% faster than   Out 956,0.      Four percent may not seem like much, but multiply that by the number of times it is used, and the number of nodes installed.

 

UBASIC Commands

CLR A is faster than A = 0.

DEC A is faster than A = A - 1.

ENCODE(string)  makes VAL faster.

INC A is faster than A = A + 1.

NEG A is equivalent to A = -A, but faster.