private static TimeMeasureProfiler <TResult> WithFunctionCore <TTuple, TResult>(FuncFactory <TTuple, TResult> factory, Action <TimeMeasureOptions> setup) where TTuple : Template { var options = setup.ConfigureOptions(); var descriptor = options.MethodDescriptor?.Invoke() ?? new MethodDescriptor(factory.DelegateInfo); var profiler = new TimeMeasureProfiler <TResult>() { Member = descriptor.ToString(), Data = descriptor.MergeParameters(options.RuntimeParameters ?? factory.GenericArguments.ToArray()) }; PerformTimeMeasuring(profiler, options, p => p.Result = factory.ExecuteMethod()); return(profiler); }
private static async Task <TimeMeasureProfiler <TResult> > WithFunctionAsyncCore <TTuple, TResult>(TaskFuncFactory <TTuple, TResult> factory, Action <TimeMeasureOptions> setup) where TTuple : Template { var options = setup.ConfigureOptions(); var descriptor = options.MethodDescriptor?.Invoke() ?? new MethodDescriptor(factory.DelegateInfo); var profiler = new TimeMeasureProfiler <TResult>() { Member = descriptor.ToString(), Data = descriptor.MergeParameters(options.RuntimeParameters ?? factory.GenericArguments.ToArray()) }; await PerformTimeMeasuringAsync(profiler, options, async p => p.Result = await factory.ExecuteMethodAsync().ContinueWithSuppressedContext()).ContinueWithSuppressedContext(); return(profiler); }