RKBenchmark Class Reference
Inherits from | NSObject |
Declared in | RKBenchmark.h |
Overview
The RKBenchmark
classes provide a simple, lightweight interface for quickly benchmarking the performance of units of code. Benchmark objects can be used procedurally, by manually starting & stopping the benchmark, or using a block interface to measure the execution time of the block.
Tasks
Accessing Benchmark Values
-
name
A name for the benchmark. Can be nil.
property -
startTime
The start time of the benchmark as an absolute time value.
property -
endTime
The end time of the benchmark as an absolute time value.
property -
elapsedTime
The elapsed time of the benchmark as determined by subtracting the end time from the start time. Returns zero until the benchmark has been stopped.
property
Quickly Performing Benchmarks
-
+ report:executionBlock:
-
+ measureWithExecutionBlock:
Performs a benchmark and returns a time interval measurement of the total time elapsed during the execution of the blocl.
Creating Benchmark Objects
-
+ instanceWithName:
Retrieves or creates a benchmark object instance with a given name.
-
+ benchmarkWithName:
Creates and returns a benchmark object with a name.
-
– initWithName:
Initializes a new benchmark object with a name.
Performing Benchmarks
-
– run:
Runs a benchmark by starting the receiver, executing the block, and then stopping the benchmark object.
-
– start
Starts the benchmark by recording the start time.
-
– stop
Stops the benchmark by recording the stop time.
-
– log
Logs the current benchmark status. If the receiver has been stopped, the elapsed time of the benchmark is logged. If the benchmark is still running, the total time since the benchmark was started is logged.
Properties
elapsedTime
The elapsed time of the benchmark as determined by subtracting the end time from the start time. Returns zero until the benchmark has been stopped.
@property (nonatomic, assign, readonly) CFTimeInterval elapsedTime
Declared In
RKBenchmark.h
endTime
The end time of the benchmark as an absolute time value.
@property (nonatomic, assign, readonly) CFAbsoluteTime endTime
Declared In
RKBenchmark.h
name
A name for the benchmark. Can be nil.
@property (nonatomic, strong) NSString *name
Declared In
RKBenchmark.h
startTime
The start time of the benchmark as an absolute time value.
@property (nonatomic, assign, readonly) CFAbsoluteTime startTime
Declared In
RKBenchmark.h
Class Methods
benchmarkWithName:
Creates and returns a benchmark object with a name.
+ (id)benchmarkWithName:(NSString *)name
Parameters
- name
A name for the benchmark.
Return Value
A new benchmark object with the given name.
Declared In
RKBenchmark.h
instanceWithName:
Retrieves or creates a benchmark object instance with a given name.
+ (RKBenchmark *)instanceWithName:(NSString *)name
Parameters
- name
A name for the benchmark.
Return Value
A new or existing benchmark object with the given name.
Declared In
RKBenchmark.h
measureWithExecutionBlock:
Performs a benchmark and returns a time interval measurement of the total time elapsed during the execution of the blocl.
+ (CFTimeInterval)measureWithExecutionBlock:(void ( ^ ) ( void ))block
Parameters
- block
A block to execute and measure the elapsed time during execution.
Return Value
A time interval equal to the total time elapsed during execution.
Declared In
RKBenchmark.h
Instance Methods
initWithName:
Initializes a new benchmark object with a name.
- (id)initWithName:(NSString *)name
Parameters
- name
The name to initialize the receiver with.
Return Value
The receiver, initialized with the given name.
Declared In
RKBenchmark.h
log
Logs the current benchmark status. If the receiver has been stopped, the elapsed time of the benchmark is logged. If the benchmark is still running, the total time since the benchmark was started is logged.
- (void)log
Declared In
RKBenchmark.h