Show / Hide Table of Contents

    Class BenchmarkContext

    Contains the runtime context for a given benchmark run.

    Makes it possible for developers to access built-in Counters declared via the CounterMeasurementAttribute, CounterThroughputAssertionAttribute, and CounterTotalAssertionAttribute classes.

    Inheritance
    System.Object
    BenchmarkContext
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: NBench
    Assembly: NBench.dll
    Syntax
    public sealed class BenchmarkContext

    Constructors

    BenchmarkContext(IReadOnlyDictionary<CounterMetricName, Counter>, IBenchmarkTrace)

    Declaration
    public BenchmarkContext(IReadOnlyDictionary<CounterMetricName, Counter> counters, IBenchmarkTrace trace)
    Parameters
    Type Name Description
    System.Collections.Generic.IReadOnlyDictionary<CounterMetricName, Counter> counters
    IBenchmarkTrace trace

    Properties

    CounterNames

    The names of all available counters

    Declaration
    public IEnumerable<string> CounterNames { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<System.String>

    Counters

    All available counters

    Declaration
    public IEnumerable<Counter> Counters { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<Counter>

    Trace

    Allows NBench users to write custom messages directly into the NBench output.

    Declaration
    public IBenchmarkTrace Trace { get; }
    Property Value
    Type Description
    IBenchmarkTrace

    Methods

    CounterExists(String)

    Determines if a counter with a particular name has been registered or not.

    Declaration
    public bool CounterExists(string name)
    Parameters
    Type Name Description
    System.String name

    The name of the counter.

    Returns
    Type Description
    System.Boolean

    true if it's been registered, false otherwise.

    GetCounter(String)

    Retrieves a named Counter instance that has already been registered via a CounterMeasurementAttribute, CounterThroughputAssertionAttribute, or CounterTotalAssertionAttribute classes.

    Declaration
    public Counter GetCounter(string name)
    Parameters
    Type Name Description
    System.String name

    The name of the counter.

    Returns
    Type Description
    Counter

    The corresponding Counter instance.

    Back to top Copyright © 2015-2020 Petabridge™, LLC