Simple Benchmark (don't use blocks)
#import "RAIIBenchmark.h"
beginBench(@"single test", {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.calendar = [NSCalendar currentCalendar];
[dateFormatter stringFromDate:[NSDate date]];
})
// => single test | 0.001s
// 1000 times
beginBenchLoop(@"loop case", 1000, {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.calendar = [NSCalendar currentCalendar];
[dateFormatter stringFromDate:[NSDate date]];
})
// => loop case | Total :0.544s | Average: 0.001s
// not require __block
NSMutableArray *array = [NSMutableArray array];
beginBenchLoop(@"mutable case", 1000, {
[array addObject:@"test"];
})
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT
RAII