IBenchmarkSetting implementation for TimingMeasurementAttribute and other derived versions.
상속: IBenchmarkSetting
        public override IEnumerable <IBenchmarkSetting> GetBenchmarkSettings(TimingMeasurementAttribute instance)
        {
            var elapsedTimeAssertionAttribute = instance as ElapsedTimeAssertionAttribute;
            var settings   = new List <TimingBenchmarkSetting>();
            var metricName = (TimingMetricName)GetName(instance);

            if (elapsedTimeAssertionAttribute == null)
            {
                settings.Add(new TimingBenchmarkSetting(metricName, Assertion.Empty));
                return(settings);
            }

            Contract.Assert(elapsedTimeAssertionAttribute.MaxTimeMilliseconds > 0);
            if (elapsedTimeAssertionAttribute.MinTimeMilliseconds == 0)
            {
                var setting = new TimingBenchmarkSetting(metricName,
                                                         new Assertion(MustBe.LessThanOrEqualTo, elapsedTimeAssertionAttribute.MaxTimeMilliseconds, null));
                settings.Add(setting);
            }
            else
            {
                Contract.Assert(elapsedTimeAssertionAttribute.MinTimeMilliseconds >= 0); // no negative values allowed
                var setting = new TimingBenchmarkSetting(metricName,
                                                         new Assertion(MustBe.Between, elapsedTimeAssertionAttribute.MinTimeMilliseconds, elapsedTimeAssertionAttribute.MaxTimeMilliseconds));
                settings.Add(setting);
            }

            return(settings);
        }
예제 #2
0
 private bool Equals(TimingBenchmarkSetting other)
 {
     return(MetricName.Equals(other.MetricName) && AssertionType == other.AssertionType && Assertion.Equals(other.Assertion));
 }
예제 #3
0
 private bool Equals(TimingBenchmarkSetting other)
 {
     return MetricName.Equals(other.MetricName) && AssertionType == other.AssertionType && Assertion.Equals(other.Assertion);
 }