Example #1
0
        /// <summary>
        /// The variance of the timings list sample
        /// </summary>
        /// <param name="enumTiming">Type of timing point</param>
        /// <returns>How far the timings list values are spread out from the mean</returns>
        public double Variance([DefaultParameterValue(EnumTiming.NotSpecified)] EnumTiming enumTiming)
        {
            try
            {
                IEnumerable <double> valueList =
                    Timings.Where(v => v.Item1 == enumTiming)
                    .DefaultIfEmpty()
                    .Select(v => v.Item2.Duration.TotalMilliseconds);

                return(Statistics.Variance(valueList));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to calculate the variance of the sample");
                Console.WriteLine(ex.Message);
                return(0d);
            }
        }