Credit goes to NSHipster: http://nshipster.com/benchmarking/
- Add the following to the bridging header:
#include <stdint.h>
extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));- Benchmark any code using:
let time = dispatch_benchmark(10) {
// BENCHMARK ME!
}
NSLog("Avg. Runtime: %llu ns", time)