wswan:guide:optimization
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wswan:guide:optimization [2025/12/31 12:49] – asie | wswan:guide:optimization [2026/02/11 18:53] (current) – asie | ||
|---|---|---|---|
| Line 17: | Line 17: | ||
| * For data stored in RAM, use the smallest type possible. | * For data stored in RAM, use the smallest type possible. | ||
| * Exception: For argument passing, there is little reason to prefer '' | * Exception: For argument passing, there is little reason to prefer '' | ||
| - | * By default, GCC allows function call arguments to accumulate on the stack, then pops them all at once. To reduce stack usage at the cost of a larger and slightly slower program, compile your code with '' | + | * By default, GCC allows function call arguments to accumulate on the stack, then pops them all at once. To reduce |
| ===== Optimizing assembly code ===== | ===== Optimizing assembly code ===== | ||
| Line 36: | Line 36: | ||
| There are also some additional tricks you can take advantage of: | There are also some additional tricks you can take advantage of: | ||
| - | * Avoid far calls between functions - branches are expensive, and far branches are significantly more expensive. If you're calling a far function from another far function in the same section, use '' | + | * Avoid far calls between functions - branches are expensive, and far branches are significantly more expensive. If you're calling a far function from another far function in the same section, use the '' |
| * Try word-aligning loop labels by prepending them with '' | * Try word-aligning loop labels by prepending them with '' | ||
| + | |||
| + | ===== Measuring programs ===== | ||
| + | |||
| + | ==== Measuring code size ==== | ||
| + | |||
| + | Wonderful Toolchain comes with a tool for observing the RAM/ROM allocation and per-symbol sizes: '' | ||
| + | |||
| + | ==== Measuring performance ==== | ||
| + | |||
| + | The best option is to use Mesen 2's profiler. While Mesen 2 is not 100% cycle-accurate for the WonderSwan yet, it's close enough for non-demoscene use cases. | ||
| + | |||
| + | TODO: Document how to use it. | ||
wswan/guide/optimization.1767185366.txt.gz · Last modified: by asie
