Esempio n. 1
0
        /// <summary>
        /// Internal constructor for Chronometer. Initializes a new instance of Chronometer with the given options.
        /// </summary>
        /// <param name="options"><see cref="ChronometerOptions"/></param>
        /// <param name="normalizedMeanCalculator">Implementation of <see cref="INormalizedMeanCalculator"/></param>
        /// <param name="timerFactory">Implementation of <see cref="ITimerFactory"/></param>
        /// <param name="memoryOptimizer">Implementation of <see cref="IMemoryOptimizer"/></param>
        /// <param name="performanceOptimizer">Implementation of <see cref="IPerformanceOptimizer"/></param>
        /// <param name="debugModeDetector">Implementation of <see cref="IDebugModeDetector"/></param>
        internal Chronometer(
            ChronometerOptions options,
            INormalizedMeanCalculator normalizedMeanCalculator,
            ITimerFactory timerFactory,
            IMemoryOptimizer memoryOptimizer,
            IPerformanceOptimizer performanceOptimizer,
            IDebugModeDetector debugModeDetector)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (options.NumberOfInterations == null)
            {
                throw new ArgumentException(Properties.Resources.NumberOfIterationsLessThan1ExceptionMessage, "options");
            }

            if (options.NumberOfInterations.HasValue && options.NumberOfInterations.Value < 1)
            {
                throw new ArgumentException(Properties.Resources.NumberOfIterationsLessThan1ExceptionMessage, "options");
            }

            if (normalizedMeanCalculator == null)
            {
                throw new ArgumentNullException("normalizedMeanCalculator");
            }

            if (timerFactory == null)
            {
                throw new ArgumentNullException("timerFactory");
            }

            if (memoryOptimizer == null)
            {
                throw new ArgumentNullException("memoryOptimizer");
            }

            if (performanceOptimizer == null)
            {
                throw new ArgumentNullException("performanceOptimizer");
            }

            if (debugModeDetector == null)
            {
                throw new ArgumentNullException("debugModeDetector");
            }

            Options = options;
            _normalizedMeanCalculator = normalizedMeanCalculator;
            _timerFactory             = timerFactory;
            _memoryOptimizer          = memoryOptimizer;
            _performanceOptimizer     = performanceOptimizer;
            _debugModeDetector        = debugModeDetector;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the class <see cref="BenchShark"/>.
        /// </summary>
        /// <param name="mustStoreIterations">
        /// Determines whether the evaluation must store the result of each iteration (does not alter the exposed properties).
        /// If this value is set to <c>true</c>, the evaluation can be memory consuming, depending on the number of iterations.
        /// </param>
        /// <param name="cleanUpInterval">The number of interval of iteration to perform a memory clean up.</param>
        public BenchShark(bool mustStoreIterations = false, uint cleanUpInterval = 1)
        {
            // Initialize members
            Tasks                        = new Dictionary <string, Action>();
            CleanUpInterval              = cleanUpInterval;
            MustStoreIterations          = mustStoreIterations;
            EnableUnoptimizedEvaluations = false;

            // Define the default handlers
            MemoryOptimizerHandler      = new GcMemoryOptimizer();
            PerformanceOptimizerHandler = new GcPerformanceOptimizer();
        }
Esempio n. 3
0
        /// <summary>
        /// Internal constructor for Chronometer. Initializes a new instance of Chronometer with the given options.
        /// </summary>
        /// <param name="options"><see cref="ChronometerOptions"/></param>
        /// <param name="normalizedMeanCalculator">Implementation of <see cref="INormalizedMeanCalculator"/></param>
        /// <param name="timerFactory">Implementation of <see cref="ITimerFactory"/></param>
        /// <param name="memoryOptimizer">Implementation of <see cref="IMemoryOptimizer"/></param>
        /// <param name="performanceOptimizer">Implementation of <see cref="IPerformanceOptimizer"/></param>
        /// <param name="debugModeDetector">Implementation of <see cref="IDebugModeDetector"/></param>
        internal Chronometer(
            ChronometerOptions options, 
            INormalizedMeanCalculator normalizedMeanCalculator,
            ITimerFactory timerFactory,
            IMemoryOptimizer memoryOptimizer,
            IPerformanceOptimizer performanceOptimizer,
            IDebugModeDetector debugModeDetector)
        {
            if(options == null)
                throw new ArgumentNullException("options");

            if(options.NumberOfInterations == null)
                throw new ArgumentException(Properties.Resources.NumberOfIterationsLessThan1ExceptionMessage, "options");

            if(options.NumberOfInterations.HasValue && options.NumberOfInterations.Value < 1)
                throw new ArgumentException(Properties.Resources.NumberOfIterationsLessThan1ExceptionMessage, "options");

            if(normalizedMeanCalculator == null)
                throw new ArgumentNullException("normalizedMeanCalculator");

            if(timerFactory == null)
                throw new ArgumentNullException("timerFactory");

            if (memoryOptimizer == null)
                throw new ArgumentNullException("memoryOptimizer");

            if (performanceOptimizer == null)
                throw new ArgumentNullException("performanceOptimizer");

            if (debugModeDetector == null)
                throw new ArgumentNullException("debugModeDetector");

            Options = options;
            _normalizedMeanCalculator = normalizedMeanCalculator;
            _timerFactory = timerFactory;
            _memoryOptimizer = memoryOptimizer;
            _performanceOptimizer = performanceOptimizer;
            _debugModeDetector = debugModeDetector;
        }