My demo completely failed (Mac locked up when connecting to the projector) so I couldn't show what I wanted. If you want to try the demos yourself these are the Github branches I was going show. All these are 70 pixel square calculations for consistent comparison the main master branch increases in later versions.
If you want the details I have already blogged about most of of these changes but this post is a short summary of these posts and links to example branches with code at particular stages. Previous articles:
- Optimising Swift with Functional Style 40x Inner Loop speedup from changing 1 keyword.
- Drawing images from pixel data - in Swift
- Getting uglier, multiple queues, inlining calls etc.
Note that even with these there is room to improve there may be faster rendering code and I'm experimenting with Accelerate which uses SIMD instructions to go even faster. Another post to follow if I get it running. Any other suggestions or tips welcome.
All performance figures on iPad Retina Mini.
0 - Simon Gladwell's original code with modified performance logging (to keep the results consistent with the later versions). Branch 0 Debug performs about 10fps and displays most of them. Release build about 40fps calculated but less than 1fps actually displayed (timer used rather than proper calls back to the main thread).
1 - Converted to GCD and Swift arrays. Branch 1. Debug performs worse than original but Release is more consistent on display at 12fps. From this version I was planning to convert GrayScottStruct from a class to a struct for a 40x speedup in the renderer. The whole system frame rate goes up to 56fps. (delete class and replace with struct and delete " : GrayScottProtocol" so it looks like this:
2 - Next the render process was the bottleneck and that is rewritten in Branch 2 and the speed goes upto about 450fps.
Full Speed - The full speed latest multithreaded version runs at about 1500fps! Branch - fullSpeed.
The fullspeed branch can also be built for OS X. 12000fps at 128px square although it sometimes crashes. There may be a race condition...