An Example of Code Optimization for Performance
 

An Example of Code Optimization for Performance

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.

Change and cumulative change in frames per second after each optimization. "RC" means a test with Release Configuration, for these tests all profiling and other instrumentation are turned off. [Expand]
Note Frames ms fps Change Index
Start4513002150-100
Batch transform of vertices in transformToScreen47630051585%105
Better intersection code reusing vectors547300518214%121
Caching shared transformed vertices when generating subdivision face614300320412%136
Don't recalculate transform matrices unnecessarily. Some optimizations in transformToScreen67430022249%149
Better polygons / plane clipping69530032313%154
Inhibit event firing when there are no listeners999300233243%221
RC 112283002409
Switch to using NumberBuffers1200303639518%263
RC 215503040509
Precomputed index buffers125030464103%273
Iterate with NumberBuffer.next()12003004399-2%265
RC 316003079519