C# Class NBench.Sdk.Compiler.ReflectionDiscovery

IDiscovery implementation built using reflection
Inheritance: IDiscovery
显示文件 Open project: petabridge/NBench Class Usage Examples

Public Properties

Property Type Description
BenchmarkContextType System.Type
MeasurementAttributeType System.Type
MeasurementConfiguratorType System.Type
PerformanceBenchmarkAttributeType System.Type

Public Methods

Method Description
ClassesWithPerformanceBenchmarks ( Assembly targetAssembly ) : IReadOnlyList

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

ConfiguratorSupportsMeasurement ( Type measurementType, Type expectedConfiguratorType, bool exact = false ) : bool

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

CreateBenchmarksForClass ( Type classWithBenchmarks ) : IReadOnlyList
CreateBenchmarksForClass ( TypeInfo classWithBenchmarks ) : IReadOnlyList
CreateInvokerForBenchmark ( BenchmarkClassMetadata benchmarkClass ) : IBenchmarkInvoker
CreateSettingsForBenchmark ( BenchmarkClassMetadata benchmarkClass ) : BenchmarkSettings
FindBenchmarks ( Assembly targetAssembly ) : IEnumerable
FindBenchmarks ( Type targetType ) : IEnumerable
FindBestMatchingConfiguratorForMeasurement ( Type measurementType, IEnumerable knownConfigurators ) : Type
GetCleanupMethod ( TypeInfo classWithBenchmarks ) : BenchmarkMethodMetadata
GetConfiguratorForMeasurement ( Type measurementType, Assembly specificAssembly = null ) : IMeasurementConfigurator

Creates a IMeasurementConfigurator instance for the provided MeasurementAttribute type.

GetConfiguratorTypeForMeasurement ( Type measurementType, Assembly specificAssembly = null ) : Type

Finds a matching IMeasurementConfigurator{T} type for a given type of MeasurementAttribute

GetSetupMethod ( TypeInfo classWithBenchmarks ) : BenchmarkMethodMetadata
IsTypeInvalidForBenchmarks ( TypeInfo info ) : bool
IsValidConfiguratorType ( Type configuratorType ) : bool

Check if a given configuratorType is a valid implementation of IMeasurementConfigurator{T}.

LoadAllTypeConfigurators ( ) : IEnumerable
MethodTakesBenchmarkContext ( MethodInfo info ) : bool
ReflectionDiscovery ( IBenchmarkOutput output ) : System
ReflectionDiscovery ( IBenchmarkOutput output, IBenchmarkAssertionRunner benchmarkAssertions, RunnerSettings settings ) : System

Private Methods

Method Description
GetConfiguratorInterfaces ( Type type ) : IEnumerable
MethodHasValidBenchmark ( MethodInfo x ) : bool
SupportsType ( Type measurementType, Type configuratorType, bool exact ) : bool
ValidateTypeIsMeasurementAttribute ( Type measurementType ) : void

Method Details

ClassesWithPerformanceBenchmarks() public static method

Finds all classes with at least one method decorated with a PerfBenchmarkAttribute. inside targetAssembly.
public static ClassesWithPerformanceBenchmarks ( Assembly targetAssembly ) : IReadOnlyList
targetAssembly System.Reflection.Assembly The assembly we're scanning for benchmarks.
return IReadOnlyList

ConfiguratorSupportsMeasurement() public static method

Determine if a given IMeasurementConfigurator type is a match for a MeasurementAttribute type.
public static ConfiguratorSupportsMeasurement ( Type measurementType, Type expectedConfiguratorType, bool exact = false ) : bool
measurementType System.Type A type.
expectedConfiguratorType System.Type A type.
exact bool /// 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 . ///
return bool

CreateBenchmarksForClass() public static method

public static CreateBenchmarksForClass ( Type classWithBenchmarks ) : IReadOnlyList
classWithBenchmarks System.Type
return IReadOnlyList

CreateBenchmarksForClass() public static method

public static CreateBenchmarksForClass ( TypeInfo classWithBenchmarks ) : IReadOnlyList
classWithBenchmarks System.Reflection.TypeInfo
return IReadOnlyList

CreateInvokerForBenchmark() public static method

public static CreateInvokerForBenchmark ( BenchmarkClassMetadata benchmarkClass ) : IBenchmarkInvoker
benchmarkClass BenchmarkClassMetadata
return IBenchmarkInvoker

CreateSettingsForBenchmark() public method

public CreateSettingsForBenchmark ( BenchmarkClassMetadata benchmarkClass ) : BenchmarkSettings
benchmarkClass BenchmarkClassMetadata
return BenchmarkSettings

FindBenchmarks() public method

public FindBenchmarks ( Assembly targetAssembly ) : IEnumerable
targetAssembly System.Reflection.Assembly
return IEnumerable

FindBenchmarks() public method

public FindBenchmarks ( Type targetType ) : IEnumerable
targetType System.Type
return IEnumerable

FindBestMatchingConfiguratorForMeasurement() public static method

public static FindBestMatchingConfiguratorForMeasurement ( Type measurementType, IEnumerable knownConfigurators ) : Type
measurementType System.Type
knownConfigurators IEnumerable
return System.Type

GetCleanupMethod() public static method

public static GetCleanupMethod ( TypeInfo classWithBenchmarks ) : BenchmarkMethodMetadata
classWithBenchmarks System.Reflection.TypeInfo
return BenchmarkMethodMetadata

GetConfiguratorForMeasurement() public method

Creates a IMeasurementConfigurator instance for the provided MeasurementAttribute type.
public GetConfiguratorForMeasurement ( Type measurementType, Assembly specificAssembly = null ) : IMeasurementConfigurator
measurementType System.Type A type of
specificAssembly System.Reflection.Assembly /// Optional parameter. If an is provided, we limit our search /// for definitions to just that target assembly. ///
return IMeasurementConfigurator

GetConfiguratorTypeForMeasurement() public method

Finds a matching IMeasurementConfigurator{T} type for a given type of MeasurementAttribute
public GetConfiguratorTypeForMeasurement ( Type measurementType, Assembly specificAssembly = null ) : Type
measurementType System.Type A type of
specificAssembly System.Reflection.Assembly /// Optional parameter. If an is provided, we limit our search /// for definitions to just that target assembly. ///
return System.Type

GetSetupMethod() public static method

public static GetSetupMethod ( TypeInfo classWithBenchmarks ) : BenchmarkMethodMetadata
classWithBenchmarks System.Reflection.TypeInfo
return BenchmarkMethodMetadata

IsTypeInvalidForBenchmarks() public static method

public static IsTypeInvalidForBenchmarks ( TypeInfo info ) : bool
info System.Reflection.TypeInfo
return bool

IsValidConfiguratorType() public static method

Check if a given configuratorType is a valid implementation of IMeasurementConfigurator{T}.
public static IsValidConfiguratorType ( Type configuratorType ) : bool
configuratorType System.Type The we're going to test.
return bool

LoadAllTypeConfigurators() public static method

public static LoadAllTypeConfigurators ( ) : IEnumerable
return IEnumerable

MethodTakesBenchmarkContext() public static method

public static MethodTakesBenchmarkContext ( MethodInfo info ) : bool
info System.Reflection.MethodInfo
return bool

ReflectionDiscovery() public method

public ReflectionDiscovery ( IBenchmarkOutput output ) : System
output IBenchmarkOutput
return System

ReflectionDiscovery() public method

public ReflectionDiscovery ( IBenchmarkOutput output, IBenchmarkAssertionRunner benchmarkAssertions, RunnerSettings settings ) : System
output IBenchmarkOutput
benchmarkAssertions IBenchmarkAssertionRunner
settings RunnerSettings
return System

Property Details

BenchmarkContextType public_oe static_oe property

public static Type,System BenchmarkContextType
return System.Type

MeasurementAttributeType public_oe static_oe property

public static Type,System MeasurementAttributeType
return System.Type

MeasurementConfiguratorType public_oe static_oe property

public static Type,System MeasurementConfiguratorType
return System.Type

PerformanceBenchmarkAttributeType public_oe static_oe property

public static Type,System PerformanceBenchmarkAttributeType
return System.Type