C# Class NBench.Sdk.Benchmark

Executor class for running a single PerfBenchmarkAttribute Exposes the BenchmarkContext, which allows developers to register custom metrics and counters for the use of their personal benchmarks.
ファイルを表示 Open project: petabridge/NBench Class Usage Examples

Public Properties

Property Type Description
StopWatch Stopwatch

Protected Properties

Property Type Description
Builder NBench.Sdk.BenchmarkBuilder
WarmupData WarmupData

Public Methods

Method Description
AssertResults ( NBench.Reporting.BenchmarkResults result ) : NBench.Reporting.BenchmarkFinalResults
Benchmark ( NBench.Sdk.BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer ) : System

Backwards-compatible constructor for NBench 0.1.6 and earlier.

Uses the DefaultBenchmarkAssertionRunner to assert benchmark data.

Benchmark ( NBench.Sdk.BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer, IBenchmarkAssertionRunner benchmarkAssertions ) : System

Backwards-compatible constructor for NBench 0.1.6 and earlier.

CompileResults ( ) : NBench.Reporting.BenchmarkResults

Compiles all of the completed BenchmarkRuns into reports

Finish ( ) : void

Complete the benchmark

PrepareForRun ( ) : void

Performs any final GC needed before we start a test run

Run ( ) : void
Shutdown ( ) : void

Protected Methods

Method Description
PostRun ( ) : void

NOTE: We don't reset the Stopwatch on purpose here, so we can collect the value of it and use it for auto-tuning and reporting. It'll be started at the beginning of the next run.

PreRun ( ) : void
RunBenchmark ( ) : void

Private Methods

Method Description
Allocate ( ) : void

Pre-allocate all of the objects we're going to need for this benchmark

Complete ( bool isEstimate = false ) : void

Complete the current run

HandleBenchmarkRunException ( Exception ex, string formatMsg ) : void
PrintWarmupOrRun ( bool isWarmup ) : string

Helper method for printing out the correct label to trace

RunSingleBenchmark ( ) : void
WarmUp ( ) : void

Warmup phase

Method Details

AssertResults() public method

public AssertResults ( NBench.Reporting.BenchmarkResults result ) : NBench.Reporting.BenchmarkFinalResults
result NBench.Reporting.BenchmarkResults
return NBench.Reporting.BenchmarkFinalResults

Benchmark() public method

Backwards-compatible constructor for NBench 0.1.6 and earlier.
Uses the DefaultBenchmarkAssertionRunner to assert benchmark data.
public Benchmark ( NBench.Sdk.BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer ) : System
settings NBench.Sdk.BenchmarkSettings The settings for this benchmark.
invoker IBenchmarkInvoker The invoker used to execute benchmark and setup / cleanup methods.
writer IBenchmarkOutput The output target this benchmark will write to.
return System

Benchmark() public method

Backwards-compatible constructor for NBench 0.1.6 and earlier.
public Benchmark ( NBench.Sdk.BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer, IBenchmarkAssertionRunner benchmarkAssertions ) : System
settings NBench.Sdk.BenchmarkSettings The settings for this benchmark.
invoker IBenchmarkInvoker The invoker used to execute benchmark and setup / cleanup methods.
writer IBenchmarkOutput The output target this benchmark will write to.
benchmarkAssertions IBenchmarkAssertionRunner The assertion engine we'll use to perform BenchmarkAssertions against benchmarks.
return System

CompileResults() public method

Compiles all of the completed BenchmarkRuns into reports
public CompileResults ( ) : NBench.Reporting.BenchmarkResults
return NBench.Reporting.BenchmarkResults

Finish() public method

Complete the benchmark
public Finish ( ) : void
return void

PostRun() protected method

NOTE: We don't reset the Stopwatch on purpose here, so we can collect the value of it and use it for auto-tuning and reporting. It'll be started at the beginning of the next run.
protected PostRun ( ) : void
return void

PreRun() protected method

protected PreRun ( ) : void
return void

PrepareForRun() public static method

Performs any final GC needed before we start a test run
public static PrepareForRun ( ) : void
return void

Run() public method

public Run ( ) : void
return void

RunBenchmark() protected method

protected RunBenchmark ( ) : void
return void

Shutdown() public method

public Shutdown ( ) : void
return void

Property Details

Builder protected_oe property

protected BenchmarkBuilder,NBench.Sdk Builder
return NBench.Sdk.BenchmarkBuilder

StopWatch public_oe property

Stopwatch used by the Benchmark. Exposed only for testing purposes.
public Stopwatch StopWatch
return Stopwatch

WarmupData protected_oe property

protected WarmupData,NBench.Sdk WarmupData
return WarmupData