Show / Hide Table of Contents

    Class ReflectionDiscovery

    IDiscovery implementation built using reflection

    Inheritance
    System.Object
    ReflectionDiscovery
    Implements
    IDiscovery
    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.Sdk.Compiler
    Assembly: NBench.dll
    Syntax
    public class ReflectionDiscovery : IDiscovery

    Constructors

    ReflectionDiscovery(IBenchmarkOutput)

    Declaration
    public ReflectionDiscovery(IBenchmarkOutput output)
    Parameters
    Type Name Description
    IBenchmarkOutput output

    ReflectionDiscovery(IBenchmarkOutput, IBenchmarkAssertionRunner, RunnerSettings)

    Declaration
    public ReflectionDiscovery(IBenchmarkOutput output, IBenchmarkAssertionRunner benchmarkAssertions, RunnerSettings settings)
    Parameters
    Type Name Description
    IBenchmarkOutput output
    IBenchmarkAssertionRunner benchmarkAssertions
    RunnerSettings settings

    Fields

    BenchmarkContextType

    Declaration
    public static readonly Type BenchmarkContextType
    Field Value
    Type Description
    System.Type

    MeasurementAttributeType

    Declaration
    public static readonly Type MeasurementAttributeType
    Field Value
    Type Description
    System.Type

    MeasurementConfiguratorType

    Declaration
    public static readonly Type MeasurementConfiguratorType
    Field Value
    Type Description
    System.Type

    PerformanceBenchmarkAttributeType

    Declaration
    public static readonly Type PerformanceBenchmarkAttributeType
    Field Value
    Type Description
    System.Type

    Properties

    BenchmarkAssertions

    Declaration
    public IBenchmarkAssertionRunner BenchmarkAssertions { get; }
    Property Value
    Type Description
    IBenchmarkAssertionRunner

    Output

    Declaration
    public IBenchmarkOutput Output { get; }
    Property Value
    Type Description
    IBenchmarkOutput

    RunnerSettings

    Declaration
    public RunnerSettings RunnerSettings { get; }
    Property Value
    Type Description
    RunnerSettings

    Trace

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

    Methods

    ClassesWithPerformanceBenchmarks(Assembly)

    Finds all classes with at least one method decorated with a PerfBenchmarkAttribute. inside targetAssembly.

    Declaration
    public static IReadOnlyList<TypeInfo> ClassesWithPerformanceBenchmarks(Assembly targetAssembly)
    Parameters
    Type Name Description
    System.Reflection.Assembly targetAssembly

    The assembly we're scanning for benchmarks.

    Returns
    Type Description
    System.Collections.Generic.IReadOnlyList<System.Reflection.TypeInfo>

    A list of all applicable types that contain at least one method with a PerfBenchmarkAttribute.

    ConfiguratorSupportsMeasurement(Type, Type, Boolean)

    Determine if a given IMeasurementConfigurator type is a match for a MeasurementAttribute type.

    Declaration
    public static bool ConfiguratorSupportsMeasurement(Type measurementType, Type expectedConfiguratorType, bool exact = false)
    Parameters
    Type Name Description
    System.Type measurementType

    A MeasurementAttribute type.

    System.Type expectedConfiguratorType

    A IMeasurementConfigurator type.

    System.Boolean exact

    If true, then this method will look for an exact 1:1 type match. If false, which is the default then this method will return true when any applicable types are assignable from measurementType.

    Returns
    Type Description
    System.Boolean

    true if a match was found, false otherwise.

    CreateBenchmarksForClass(TypeInfo)

    Declaration
    public static IReadOnlyList<BenchmarkClassMetadata> CreateBenchmarksForClass(TypeInfo classWithBenchmarks)
    Parameters
    Type Name Description
    System.Reflection.TypeInfo classWithBenchmarks
    Returns
    Type Description
    System.Collections.Generic.IReadOnlyList<BenchmarkClassMetadata>

    CreateBenchmarksForClass(Type)

    Declaration
    public static IReadOnlyList<BenchmarkClassMetadata> CreateBenchmarksForClass(Type classWithBenchmarks)
    Parameters
    Type Name Description
    System.Type classWithBenchmarks
    Returns
    Type Description
    System.Collections.Generic.IReadOnlyList<BenchmarkClassMetadata>

    CreateInvokerForBenchmark(BenchmarkClassMetadata)

    Declaration
    public static IBenchmarkInvoker CreateInvokerForBenchmark(BenchmarkClassMetadata benchmarkClass)
    Parameters
    Type Name Description
    BenchmarkClassMetadata benchmarkClass
    Returns
    Type Description
    IBenchmarkInvoker

    CreateSettingsForBenchmark(BenchmarkClassMetadata)

    Declaration
    public BenchmarkSettings CreateSettingsForBenchmark(BenchmarkClassMetadata benchmarkClass)
    Parameters
    Type Name Description
    BenchmarkClassMetadata benchmarkClass
    Returns
    Type Description
    BenchmarkSettings

    FindBenchmarks(Assembly)

    Declaration
    public IEnumerable<Benchmark> FindBenchmarks(Assembly targetAssembly)
    Parameters
    Type Name Description
    System.Reflection.Assembly targetAssembly
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Benchmark>

    FindBenchmarks(Type)

    Declaration
    public IEnumerable<Benchmark> FindBenchmarks(Type targetType)
    Parameters
    Type Name Description
    System.Type targetType
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Benchmark>

    FindBestMatchingConfiguratorForMeasurement(Type, IEnumerable<Type>)

    Declaration
    public static Type FindBestMatchingConfiguratorForMeasurement(Type measurementType, IEnumerable<Type> knownConfigurators)
    Parameters
    Type Name Description
    System.Type measurementType
    System.Collections.Generic.IEnumerable<System.Type> knownConfigurators
    Returns
    Type Description
    System.Type

    GetCleanupMethod(TypeInfo)

    Declaration
    public static BenchmarkMethodMetadata GetCleanupMethod(TypeInfo classWithBenchmarks)
    Parameters
    Type Name Description
    System.Reflection.TypeInfo classWithBenchmarks
    Returns
    Type Description
    BenchmarkMethodMetadata

    GetConfiguratorForMeasurement(Type, IAssemblyLoader)

    Creates a IMeasurementConfigurator instance for the provided MeasurementAttribute type.

    Declaration
    public IMeasurementConfigurator GetConfiguratorForMeasurement(Type measurementType, IAssemblyLoader specificAssembly = null)
    Parameters
    Type Name Description
    System.Type measurementType

    A type of MeasurementAttribute

    IAssemblyLoader specificAssembly

    Optional parameter. If an System.Reflection.Assembly is provided, we limit our search for IMeasurementConfigurator<T> definitions to just that target assembly.

    Returns
    Type Description
    IMeasurementConfigurator

    If a IMeasurementConfigurator type match was found, this method will return a NEW instance of that. If no match was found, we return a special case instance of MeasurementConfigurator.EmptyConfigurator.

    GetConfiguratorTypeForMeasurement(Type, IAssemblyLoader)

    Finds a matching IMeasurementConfigurator<T> type for a given type of MeasurementAttribute

    Declaration
    public Type GetConfiguratorTypeForMeasurement(Type measurementType, IAssemblyLoader specificAssembly = null)
    Parameters
    Type Name Description
    System.Type measurementType

    A type of MeasurementAttribute

    IAssemblyLoader specificAssembly

    Optional parameter. If an System.Reflection.Assembly is provided, we limit our search for IMeasurementConfigurator<T> definitions to just that target assembly.

    Returns
    Type Description
    System.Type

    A corresponding IMeasurementConfigurator<T> type

    GetSetupMethod(TypeInfo)

    Declaration
    public static BenchmarkMethodMetadata GetSetupMethod(TypeInfo classWithBenchmarks)
    Parameters
    Type Name Description
    System.Reflection.TypeInfo classWithBenchmarks
    Returns
    Type Description
    BenchmarkMethodMetadata

    IsTypeInvalidForBenchmarks(TypeInfo)

    Declaration
    public static bool IsTypeInvalidForBenchmarks(TypeInfo info)
    Parameters
    Type Name Description
    System.Reflection.TypeInfo info
    Returns
    Type Description
    System.Boolean

    IsValidConfiguratorType(Type)

    Check if a given configuratorType is a valid implementation of IMeasurementConfigurator<T>.

    Declaration
    public static bool IsValidConfiguratorType(Type configuratorType)
    Parameters
    Type Name Description
    System.Type configuratorType

    The System.Type we're going to test.

    Returns
    Type Description
    System.Boolean

    true if configuratorType implements IMeasurementConfigurator<T>, false otherwise.

    LoadAllTypeConfigurators(IAssemblyLoader)

    Declaration
    public static IEnumerable<Type> LoadAllTypeConfigurators(IAssemblyLoader loader)
    Parameters
    Type Name Description
    IAssemblyLoader loader
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Type>

    LoadAllTypeConfigurators(Assembly, IBenchmarkOutput)

    Declaration
    public static IEnumerable<Type> LoadAllTypeConfigurators(Assembly assembly, IBenchmarkOutput output = null)
    Parameters
    Type Name Description
    System.Reflection.Assembly assembly
    IBenchmarkOutput output
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Type>

    MethodTakesBenchmarkContext(MethodInfo)

    Declaration
    public static bool MethodTakesBenchmarkContext(MethodInfo info)
    Parameters
    Type Name Description
    System.Reflection.MethodInfo info
    Returns
    Type Description
    System.Boolean

    Implements

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