A simple statistical time-based benchmarking framework with nanosecond precision.
Sample the amount of time to create and fill and array with 10000 entries.
CBHBenchmarkSamples *benchmark = [CBHBenchmark benchmark:^{
NSMutableArray *array = [NSMutableArray array];
for (NSUInteger i = 0; i < 10000; ++i)
{
[array addObject:[NSString stringWithFormat:@"%lu", i]];
}
}];
/// Samples
NSUInteger count = [benchmark count];
NSArray<CBHBenchmarkSample *> *samples = [benchmark samples];
NSArray<CBHBenchmarkSample *> *sortedSamples = [benchmark sortedSamples];
/// Max, Min, and Range
CBHBenchmarkSample *min = [benchmark min];
CBHBenchmarkSample *max = [benchmark max];
CBHBenchmarkDuration *spread = [benchmark spread];
/// Mean and Median
CBHBenchmarkDuration *mean = [benchmark mean];
CBHBenchmarkDuration *median = [benchmark median];
/// Variance, Standard Deviation, Standard Error
CGFloat variance = [benchmark variance];
CBHBenchmarkDuration *standardDeviation = [benchmark standardDeviation];
CBHBenchmarkDuration *standardError = [benchmark standardError];
CBHBenchmarkKit is available under the ISC license.