Class 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.
Inheritance
Inherited Members
Namespace: NBench.Sdk
Assembly: NBench.dll
Syntax
public class Benchmark
Constructors
Benchmark(BenchmarkSettings, IBenchmarkInvoker, IBenchmarkOutput)
Backwards-compatible constructor for NBench 0.1.6 and earlier.
Declaration
public Benchmark(BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer)
Parameters
Type | Name | Description |
---|---|---|
BenchmarkSettings | settings | The settings for this benchmark. |
IBenchmarkInvoker | invoker | The invoker used to execute benchmark and setup / cleanup methods. |
IBenchmarkOutput | writer | The output target this benchmark will write to. |
Remarks
Uses the DefaultBenchmarkAssertionRunner to assert benchmark data.
Benchmark(BenchmarkSettings, IBenchmarkInvoker, IBenchmarkOutput, IBenchmarkAssertionRunner)
Backwards-compatible constructor for NBench 0.1.6 and earlier.
Declaration
public Benchmark(BenchmarkSettings settings, IBenchmarkInvoker invoker, IBenchmarkOutput writer, IBenchmarkAssertionRunner benchmarkAssertions)
Parameters
Type | Name | Description |
---|---|---|
BenchmarkSettings | settings | The settings for this benchmark. |
IBenchmarkInvoker | invoker | The invoker used to execute benchmark and setup / cleanup methods. |
IBenchmarkOutput | writer | The output target this benchmark will write to. |
IBenchmarkAssertionRunner | benchmarkAssertions | The assertion engine we'll use to perform BenchmarkAssertions against benchmarks. |
Fields
Builder
Declaration
protected readonly BenchmarkBuilder Builder
Field Value
Type | Description |
---|---|
BenchmarkBuilder |
StopWatch
Stopwatch used by the Benchmark. Exposed only for testing purposes.
Declaration
public readonly Stopwatch StopWatch
Field Value
Type | Description |
---|---|
System.Diagnostics.Stopwatch |
WarmupData
Declaration
protected WarmupData WarmupData
Field Value
Type | Description |
---|---|
WarmupData |
Properties
AllAssertsPassed
Returns true
if Finish() was called and all BenchmarkAssertions passed,
or if it was never called.
Declaration
public bool AllAssertsPassed { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
BenchmarkAssertionRunner
Declaration
protected IBenchmarkAssertionRunner BenchmarkAssertionRunner { get; }
Property Value
Type | Description |
---|---|
IBenchmarkAssertionRunner |
BenchmarkName
The name of this benchmark
Declaration
public string BenchmarkName { get; }
Property Value
Type | Description |
---|---|
System.String |
CompletedRuns
Declaration
public Queue<BenchmarkRunReport> CompletedRuns { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Queue<BenchmarkRunReport> |
Invoker
Declaration
protected IBenchmarkInvoker Invoker { get; }
Property Value
Type | Description |
---|---|
IBenchmarkInvoker |
Output
Declaration
protected IBenchmarkOutput Output { get; }
Property Value
Type | Description |
---|---|
IBenchmarkOutput |
RunMode
Declaration
public RunMode RunMode { get; }
Property Value
Type | Description |
---|---|
RunMode |
Settings
Declaration
public BenchmarkSettings Settings { get; }
Property Value
Type | Description |
---|---|
BenchmarkSettings |
ShutdownCalled
Declaration
public bool ShutdownCalled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Trace
Declaration
protected IBenchmarkTrace Trace { get; }
Property Value
Type | Description |
---|---|
IBenchmarkTrace |
Methods
AssertResults(BenchmarkResults)
Declaration
public BenchmarkFinalResults AssertResults(BenchmarkResults result)
Parameters
Type | Name | Description |
---|---|---|
BenchmarkResults | result |
Returns
Type | Description |
---|---|
BenchmarkFinalResults |
CompileResults()
Compiles all of the completed BenchmarkRuns into reports
Declaration
public BenchmarkResults CompileResults()
Returns
Type | Description |
---|---|
BenchmarkResults | The full set of aggregate results |
Finish()
Complete the benchmark
Declaration
public void Finish()
PostRun()
NOTE: We don't reset the System.Diagnostics.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.
Declaration
protected void PostRun()
PrepareForRun()
Performs any final GC needed before we start a test run
Declaration
public static void PrepareForRun()
PreRun()
Declaration
protected void PreRun()
Run()
Declaration
public void Run()
RunBenchmark()
Declaration
protected void RunBenchmark()
Shutdown()
Declaration
public void Shutdown()