Difference between revisions of "AMOS:Optimizing Miscellaneous"
Spellcoder (talk | contribs) (New page: ==Use extensions== speed increase: large Get yourself a fast extension, such as AMCAF or Turbo Plus. This will only speed things up where an extension command replaces an internal comman...) |
(No difference)
|
Revision as of 00:00, 9 December 2007
Contents
Use extensions
speed increase: large
Get yourself a fast extension, such as AMCAF or Turbo Plus. This will only speed things up where an extension command replaces an internal command with a faster one - Easylife and AMCAF will do this for many string operations and, AMCAF, Turbo and Powerbobs do it for graphics.
Don't use:
Plot x,y,c
Use this instead:
Turbo Plot x,y,c (for AMCAF) or F Plot x,y,c (for Turbo Plus)
Many extensions can be found on Aminet (FTP from wuarchive.wustl.edu in systems/amiga/aminet/dev/amos).
Use assembler
speed increase: varies
Use assembler procedures for inner loops. Beware though, it does take a small amount of CPU time to jump to an assembler procedure, so with small routines, it's simply not worth it.
Use 'Copper Off' when doing CPU intensive work
speed increase: small
Use "Copper Off" to disable the screen while doing intense communication. The copper then stops stealing clock cycles from the processor (Unlike Multi No and such instructions, this really does work). Use "Copper On" to re-enable the normal system.
Clear an array using Fill
speed increase: large
Use Fill to clear an array to a certain value, rather than the equivilant For / Next loop.
Don't use:
For n=0 to 1000 A(n)=27 Next n
Use this instead:
Fill Varptr(A(0)) To Varptr(A(1000)),27
Use global variables
speed increase: small
Use global variables to return parameters from procedures, rather than Param.
Don't use:
_HELLO[10,20] : pram=Param : Print pram Procedure _HELLO[x,y] temp=0 For n=x To y If a(n)=0 Then temp=n : Exit Next n End Proc[temp]
Use this instead:
Global pram _HELLO[10,20] : Print pram Procedure _HELLO[x,y] pram=0 For n=x To y If a(n)=0 Then pram=n : Pop Proc Next N End Proc
However, don't do things like this, which are actually slower.
Don't do:
_HELLO[10,20] : Print A Procedure _HELLO[X,Y] Shared A A=X*Y End Proc
Do this:
_HELLO[10,20] : Print Param Procedure _HELLO[X,Y] End Proc[X*Y]
Use subroutines instead of procedures
speed increase: large
Use subroutines instead of procedures. Although they're messier, they are several times faster! Of course, with this method, you can not pass parameters, but all the variables you were using will still be accessible.
Don't use:
_SOMETHING Procedure _SOMETHING Code End Proc
Use this instead:
Gosub _SOMETHING _SOMETHING: Code Return