Sus::Fixtures::BenchmarkSourceSusFixturesBenchmarkRepeats

class Repeats

Represents a benchmarking helper that executes a block multiple times, collecting timing samples until statistical convergence is reached.

Nested

Definitions

def initialize(sampler)

Initializes a new class Sus::Fixtures::Benchmark::Repeats object with a sampler to collect timing data.

Signature

parameter sampler Sampler

The sampler object to collect timing data.

Implementation

def initialize(sampler)
	@sampler = sampler
end

attr :sampler

Signature

attribute Sampler

The sampler that collects timing data.

def times(&block)

Repeatedly executes the block until the sampler reports convergence.

Signature

parameter block Proc

The block to benchmark.

Implementation

def times(&block)
	until @sampler.converged?
		sample!(block)
	end
end

def exactly(count)

Sets a fixed number of times to execute the block, returning a new class Sus::Fixtures::Benchmark::Repeats::Exactly instance.

Signature

parameter count Integer

The exact number of times to execute the block.

returns Exactly

A new instance that will execute the block exactly the specified number of times.

Implementation

def exactly(count)
	Exactly.new(@sampler, count)
end