Ejemplo n.º 1
0
        /// <summary>
        /// Runs the specified operation and returns the duration of time taken.
        /// </summary>
        /// <param name="container">The container to benchmark.</param>
        /// <param name="operation">The operation.</param>
        /// <param name="tuple">The tuple.</param>
        /// <returns>
        /// A duration
        /// </returns>
        /// <exception cref="System.ArgumentException">Operation not supported - operation</exception>
        private Action <T> GetAction <T>(IBenchmarkContainer <T> container, BenchmarkOperation operation)
        {
            Action <T> method;

            switch (operation)
            {
            case BenchmarkOperation.Delete:
                method = container.Delete;
                break;

            case BenchmarkOperation.Find:
                method = (t) => container.Find(t);
                break;

            case BenchmarkOperation.Insert:
                method = container.Insert;
                break;

            case BenchmarkOperation.Iterate:
                method = (t) => container.Iterate();
                break;

            default:
                throw new ArgumentException("Operation not supported", nameof(operation));
            }

            return(method);
        }