Inherits from NSObject
Declared in RKBenchmark.h
RKBenchmark.m

Overview

RKBenchmark objects 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

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, retain) 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

report:executionBlock:

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

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

run:

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

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

Parameters

executionBlock

A block to execute as the body of the benchmark.

Declared In

RKBenchmark.h

start

Starts the benchmark by recording the start time.

- (void)start

Declared In

RKBenchmark.h

stop

Stops the benchmark by recording the stop time.

- (void)stop

Declared In

RKBenchmark.h