Performance Testing in XCode Playgrounds
/Update I have made this available as a Swift Package (including Linux support) on GitHub so that it can be integrated into non-playground projects too.
I have been using unit tests to test performance of algorithms since the introduction of XCode 6. However, they are quite heavy weight for quickly experimenting with a couple of difference approaches.
To overcome this I've created this little playground that has a similar function to the "measurePerformance" function in XCT. You can download it here
The method measure can simply take a block that you wish to test, and it will return the average time taken to execute the block over 10 iterations
That's useful, but you might be interested in seeing all of the results (or possibly testing a few different algorithms. So, you can also provide a name for your test that will cause a graph to be plotted of the execution times of each iteration as well as the average time and standard deviation
A few notes... it's much better to supply your test code in the playground sources (cmd-0 to see them with the example playground) as it means you won't be getting the playground incremental updates slowing down the actual execution.
It's a great way of quickly iterating on different solutions to a problem you have, and making sure you have a fast implementation!