private ISingleIterationOperationResultBase BenchmarkAndExecuteInner <TOperation>(BenchmarkProcessorConfiguration benchmarkProcessorConfiguration, TOperation operation)
            where TOperation : IOperationBase
        {
            if (benchmarkProcessorConfiguration.GarbageCollectBeforeEachOperation)
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }

            if (benchmarkProcessorConfiguration.IfDebuggerIsAttachedThenThrowException && System.Diagnostics.Debugger.IsAttached)
            {
                throw new Exception("Debugger is attached. To allow benchmarks to be executed while the debugger is attached, set BenchmarkProcessorConfiguration.IfDebuggerIsAttachedThenThrowException to false.");
            }

            if (operation is IOperationGroup <IOperationBase> )
            {
                var operationTyped = (IOperationGroup <IOperationBase>)operation;
                return(BenchmarkAndExecuteInner_Group(benchmarkProcessorConfiguration, operationTyped, operationTyped.Operation1));
            }

            if (operation is IOperationGroup <IOperationBase, IOperationBase> )
            {
                var operationTyped = (IOperationGroup <IOperationBase, IOperationBase>)operation;
                return(BenchmarkAndExecuteInner_Group(benchmarkProcessorConfiguration, operationTyped, operationTyped.Operation1, operationTyped.Operation2));
            }

            if (operation is IOperationGroup <IOperationBase, IOperationBase, IOperationBase> )
            {
                var operationTyped = (IOperationGroup <IOperationBase, IOperationBase, IOperationBase>)operation;
                return(BenchmarkAndExecuteInner_Group(benchmarkProcessorConfiguration, operationTyped, operationTyped.Operation1, operationTyped.Operation2, operationTyped.Operation3));
            }

            if (operation is IOperationGroup <IOperationBase, IOperationBase, IOperationBase, IOperationBase> )
            {
                var operationTyped = (IOperationGroup <IOperationBase, IOperationBase, IOperationBase, IOperationBase>)operation;
                return(BenchmarkAndExecuteInner_Group(benchmarkProcessorConfiguration, operationTyped, operationTyped.Operation1, operationTyped.Operation2, operationTyped.Operation3, operationTyped.Operation4));
            }

            if (operation is IOperationGroup <IOperationBase, IOperationBase, IOperationBase, IOperationBase, IOperationBase> )
            {
                var operationTyped = (IOperationGroup <IOperationBase, IOperationBase, IOperationBase, IOperationBase, IOperationBase>)operation;
                return(BenchmarkAndExecuteInner_Group(benchmarkProcessorConfiguration, operationTyped, operationTyped.Operation1, operationTyped.Operation2, operationTyped.Operation3, operationTyped.Operation4, operationTyped.Operation5));
            }

            if (operation is IOperationWithAction)
            {
                IOperationWithAction operationTyped = (IOperationWithAction)operation;
                return(ExecuteInner_OperationWithAction(operationTyped));
            }

            return(ExecuteInner_OperationWithFunc((dynamic)operation));
        }
        private ISingleIterationOperationWithActionResult ExecuteInner_OperationWithAction(IOperationWithAction operation)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            operation.Delegate();

            stopwatch.Stop();

            return(new SingleIterationOperationWithActionResult()
            {
                Name = operation.Name,
                Duration = stopwatch.Elapsed,
            });
        }