private static Descriptor CreateDescriptor( Type type, MethodInfo globalSetupMethod, MethodInfo methodInfo, MethodInfo globalCleanupMethod, MethodInfo iterationSetupMethod, MethodInfo iterationCleanupMethod, BenchmarkAttribute attr, MethodInfo[] targetMethods) { var target = new Descriptor( type, methodInfo, globalSetupMethod, globalCleanupMethod, iterationSetupMethod, iterationCleanupMethod, attr.Description, baseline: attr.Baseline, categories: GetCategories(methodInfo), operationsPerInvoke: attr.OperationsPerInvoke, methodIndex: Array.IndexOf(targetMethods, methodInfo)); AssertMethodHasCorrectSignature("Benchmark", methodInfo); AssertMethodIsAccessible("Benchmark", methodInfo); AssertMethodIsNotGeneric("Benchmark", methodInfo); return(target); }
protected Benchmark CreateBenchmarkForType(Type type, BenchmarkAttribute descriptor) { Debug.Assert(type != null); var benchmark = new Benchmark(); benchmark.Type = type; benchmark.Group = ResolveValue(descriptor, () => descriptor.Group, ""); benchmark.Name = ResolveValue(descriptor, () => descriptor.Name, type.Name); benchmark.Description = ResolveValue(descriptor, () => descriptor.Description, ""); benchmark.SetUpMethods = GetInvokableMethods(type).Where(x => Attribute.IsDefined(x, typeof(SetUpBenchmarkAttribute))).ToArray(); benchmark.Methods.AddRange(FindMethodsToBenchmark(type)); benchmark.CleanUpMethods = GetInvokableMethods(type).Where(x => Attribute.IsDefined(x, typeof(CleanUpBenchmarkAttribute))).ToArray(); return(benchmark); }
private static Target CreateTarget(Type type, MethodInfo setupMethod, MethodInfo methodInfo, BenchmarkAttribute attr) { var target = new Target(type, methodInfo, setupMethod, attr.Description, baseline: attr.Baseline, operationsPerInvoke: attr.OperationsPerInvoke); AssertMethodHasCorrectSignature("Benchmark", methodInfo); AssertMethodIsAccessible("Benchmark", methodInfo); AssertMethodIsNotGeneric("Benchmark", methodInfo); return(target); }