Warning
You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
performance [2019/08/01 12:26] – [Tip #7 REPEAT ... UNTIL is faster than FOR ... NEXT] neils | performance [2021/01/10 19:21] (current) – [Tip #3: Do arithmetic only when necessary] gabrielsroka | ||
---|---|---|---|
Line 15: | Line 15: | ||
==== Tip #3: Do arithmetic only when necessary ==== | ==== Tip #3: Do arithmetic only when necessary ==== | ||
- | Even the simplest addition or substraction | + | Even the simplest addition or subtraction |
Wrong example: | Wrong example: | ||
Line 97: | Line 97: | ||
inc i! | inc i! | ||
until i! = 100 | until i! = 100 | ||
+ | | ||
+ | ==== Tip #9: Use LSHIFT() and RSHIFT() ==== | ||
+ | |||
+ | It's much faster to multiply or divide by powers of two using bit shifting operations. Use [[lshift|LSHIFT()]] and [[rshift|RSHIFT()]] whenever you can. | ||
+ | |||
+ | ==== Tip #10: Know the optimizer ==== | ||
+ | |||
+ | **XC=BASIC** features a built-in optimizer that replaces commonly used program sequences with faster opcode sequences. To make good use of the optimizer, bear in mind the following program structures that can be optimized: | ||
+ | |||
+ | * Value assignment of bytes and integers | ||
+ | * Addition of bytes and integers | ||
+ | * Subtraction of bytes and integers | ||
+ | * Comparison of bytes, e. g. '' | ||
+ | * '' | ||
+ | * Array access of byte type arrays with byte type index | ||
+ | * Bitwise operators on bytes | ||
+ | * POKE and PEEK (they' | ||
+ | |||
+ | The following are not optimized at all: | ||
+ | |||
+ | * Operations on floating point types | ||
+ | * I/O commands like '' | ||
+ | * Convenience commands like '' |