Remote-processing CAMBASIC Manual do Utilizador Página 24

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 208
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 23
Program ing Tips - 1
How to Maximize Execution Speed
1. Use the pre-compiled variable A% to Z%. In an average program these will run 50% faster. U se as many as
possible, especially in FOR/ NEXT loops and softwar e counters.
For other variables there is a lookup time. To minimize lookup time declare the variables at the beginning of
the progr am to for ce them to be at the beginning of the variable table. Put the var iables which need to
execute fastest at the beginning.
10 A=0:B=0:C=0:A$=""
2. Use constants rather than variables whenever possible in all functions and statements. Except for the pre-
compiled variables above, a “ lookup” time is required.
POKE &9000,4 fastest
POKE A%,B% fast
POKE A,B slowest
3. The speed of execution is independent of the length of the variable name.
4. Place several statements on the same line. This will yield a slight increase in speed at the expense of clarity.
5. Use INC and DEC whenever possible. T hey are much faster than the standard syntax to increment variables.
INC A% fastest
INC A fast
A=A+1 slowest
6. All string operations a re slow. T his is especially true when concatenating strings. When pr inting, avoid
string concatenation.
PRINT A$;B$ fast
PRINT A$+B$ slow
7. Certain mathematical operations have long execution times: multiply, divide, SIN, COS, ATN, SQR, LOG,
EXP and $.
8. Replace a list of conditionals w ith the ON GOT O statem ent:
10 ON X GOTO 200,300,400,500 fast
10 IF X=1 GOTO 200 very slow
20 IF X=2 GOTO 300
30 IF X=3 GOTO 400
40 IF X+4 GOTO 500
9. Even though remarks are not executed, there is a slight amount of overhead to skip over the list number. You
Vista de página 23
1 2 ... 19 20 21 22 23 24 25 26 27 28 29 ... 207 208

Comentários a estes Manuais

Sem comentários