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

Creating Benchmark Objects

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

@property (nonatomic, assign, readonly) CFTimeInterval elapsedTime
Discussion

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.

Declared In

RKBenchmark.h

endTime

@property (nonatomic, assign, readonly) CFAbsoluteTime endTime
Discussion

The end time of the benchmark as an absolute time value.

Declared In

RKBenchmark.h

name

@property (nonatomic, strong) NSString *name
Discussion

A name for the benchmark. Can be nil.

Declared In

RKBenchmark.h

startTime

@property (nonatomic, assign, readonly) CFAbsoluteTime startTime
Discussion

The start time of the benchmark as an absolute time value.

Declared In

RKBenchmark.h

Class Methods

benchmarkWithName:

+ (instancetype)benchmarkWithName:(NSString *)name
Discussion

Creates and returns a benchmark object with a name.

Parameters

name

A name for the benchmark.

Return Value

A new benchmark object with the given name.

Declared In

RKBenchmark.h

instanceWithName:

+ (RKBenchmark *)instanceWithName:(NSString *)name
Discussion

Retrieves or creates a benchmark object instance with a given 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:

+ (CFTimeInterval)measureWithExecutionBlock:(void ( ^ ) ( void ))block
Discussion

Performs a benchmark and returns a time interval measurement of the total time elapsed during the execution of the blocl.

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

report:executionBlock:

+ (id)report:(NSString *)info executionBlock:(void ( ^ ) ( void ))block

Declared In

RKBenchmark.h

Instance Methods

initWithName:

- (instancetype)initWithName:(NSString *)name
Discussion

Initializes a new benchmark object with a name.

Parameters

name

The name to initialize the receiver with.

Return Value

The receiver, initialized with the given name.

Declared In

RKBenchmark.h

log

- (void)log
Discussion

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.

Declared In

RKBenchmark.h

run:

- (void)run:(void ( ^ ) ( void ))executionBlock
Discussion

Runs a benchmark by starting the receiver, executing the block, and then stopping the benchmark object.

Parameters

executionBlock

A block to execute as the body of the benchmark.

Declared In

RKBenchmark.h

start

- (void)start
Discussion

Starts the benchmark by recording the start time.

Declared In

RKBenchmark.h

stop

- (void)stop
Discussion

Stops the benchmark by recording the stop time.

Declared In

RKBenchmark.h