Example #1
0
        public void ImprovementsreDetected(StatisticalTestKind statisticalTestKind, ThresholdUnit thresholdUnit, double thresholdValue)
        {
            var baseline = new[] { 10.0, 10.01, 10.02, 10.0, 10.03, 10.02, 9.99, 9.98, 10.0, 10.02 };
            var current  = baseline.Select(value => value * 0.97).ToArray();

            Compare(statisticalTestKind, thresholdUnit, thresholdValue, baseline, current, "Faster");
        }
Example #2
0
        private static void Compare(StatisticalTestKind statisticalTestKind, ThresholdUnit thresholdUnit, double thresholdValue, double[] baseline, double[] current, string expectedResult)
        {
            var sut = new StatisticalTestColumn(statisticalTestKind, Threshold.Create(thresholdUnit, thresholdValue));

            Assert.Equal(expectedResult, sut.GetValue(null, null, new Statistics(baseline), new Statistics(current), isBaseline: true));
            Assert.Equal(expectedResult, sut.GetValue(null, null, new Statistics(baseline), new Statistics(current), isBaseline: false));
        }
Example #3
0
        public void RegressionsAreDetected(StatisticalTestKind statisticalTestKind, ThresholdUnit thresholdUnit, double thresholdValue)
        {
            var baseline = new[] { 10.0, 10.01, 10.02, 10.0, 10.03, 10.02, 9.99, 9.98, 10.0, 10.02 };
            var current  = baseline.Select(value => value * 1.03).ToArray();

            Compare(statisticalTestKind, thresholdUnit, thresholdValue, baseline, current, "Slower");
        }
Example #4
0
        public static Threshold Create(ThresholdUnit unit, double value)
        {
            switch (unit)
            {
            case ThresholdUnit.Ratio: return(new RelativeThreshold(value));

            case ThresholdUnit.Nanoseconds: return(new AbsoluteTimeThreshold(TimeInterval.FromNanoseconds(value)));

            case ThresholdUnit.Microseconds: return(new AbsoluteTimeThreshold(TimeInterval.FromMicroseconds(value)));

            case ThresholdUnit.Milliseconds: return(new AbsoluteTimeThreshold(TimeInterval.FromMilliseconds(value)));

            case ThresholdUnit.Seconds: return(new AbsoluteTimeThreshold(TimeInterval.FromSeconds(value)));

            case ThresholdUnit.Minutes: return(new AbsoluteTimeThreshold(TimeInterval.FromMinutes(value)));

            default: throw new ArgumentOutOfRangeException(nameof(unit), unit, null);
            }
        }
Example #5
0
 internal static string ToShortName(this ThresholdUnit thresholdUnit) => UnitToShortName[thresholdUnit];
Example #6
0
        public void CanCompareDifferentSampleSizes(StatisticalTestKind statisticalTestKind, ThresholdUnit thresholdUnit, double thresholdValue)
        {
            var baseline = new[] { 10.0, 10.01, 10.02, 10.0, 10.03, 10.02, 9.99, 9.98, 10.0, 10.02 };
            var current  = baseline
                           .Skip(1) // we skip one element to make sure the sample size is different
                           .Select(value => value * 1.03).ToArray();

            Compare(statisticalTestKind, thresholdUnit, thresholdValue, baseline, current, "Slower");
        }
Example #7
0
        public void NoDifferenceIfValuesAreTheSame(StatisticalTestKind statisticalTestKind, ThresholdUnit thresholdUnit, double thresholdValue)
        {
            var values = Enumerable.Repeat(100.0, 20).ToArray();

            Compare(statisticalTestKind, thresholdUnit, thresholdValue, values, values, "Base");
        }
Example #8
0
 public StatisticalTestColumnAttribute(StatisticalTestKind testKind, ThresholdUnit thresholdUnit, double value, bool showPValues = false)
     : base(StatisticalTestColumn.Create(testKind, Threshold.Create(thresholdUnit, value), showPValues))
 {
 }