I went through some old documents and found a some notes I wrote while optimizing a renderer written in AS3/Flash. I thought I'd post it here to show how performance optimizations usually proceed: Each one usually only raises the number of frames per second by a few percent, and none doubles it, but after 10 rounds of that the code is more than twice as fast.
Note | Frames | ms | fps | Change | Index |
---|---|---|---|---|---|
Start | 451 | 3002 | 150 | - | 100 |
Batch transform of vertices in transformToScreen | 476 | 3005 | 158 | 5% | 105 |
Better intersection code reusing vectors | 547 | 3005 | 182 | 14% | 121 |
Caching shared transformed vertices when generating subdivision face | 614 | 3003 | 204 | 12% | 136 |
Don't recalculate transform matrices unnecessarily. Some optimizations in transformToScreen | 674 | 3002 | 224 | 9% | 149 |
Better polygons / plane clipping | 695 | 3003 | 231 | 3% | 154 |
Inhibit event firing when there are no listeners | 999 | 3002 | 332 | 43% | 221 |
RC 1 | 1228 | 3002 | 409 | ||
Switch to using NumberBuffers | 1200 | 3036 | 395 | 18% | 263 |
RC 2 | 1550 | 3040 | 509 | ||
Precomputed index buffers | 1250 | 3046 | 410 | 3% | 273 |
Iterate with NumberBuffer.next() | 1200 | 3004 | 399 | -2% | 265 |
RC 3 | 1600 | 3079 | 519 |