Ejemplo n.º 1
0
        internal static RatioUnit ShiftUnit(Data.SampleGroup sg)
        {
            var ru = new RatioUnit {Unit = sg.Unit, Ratio = 1D};
            if (sg.Unit == SampleUnit.Undefined) return ru;

            while (true)
            {
                var sample = sg.Median * ru.Ratio;
                if (sample > 10000)
                {
                    if (ru.Unit == SampleUnit.Second || ru.Unit == SampleUnit.Gigabyte)
                        break;

                    Shrink(ru);
                    continue;
                }

                if (sample < 10)
                {
                    if (ru.Unit == SampleUnit.Nanosecond || ru.Unit == SampleUnit.Byte)
                        break;

                    Expand(ru);
                    continue;
                }

                break;
            }

            return ru;
        }
Ejemplo n.º 2
0
        public static void UpdateStatistics(this Data.SampleGroup sampleGroup)
        {
            if (sampleGroup.Samples == null)
            {
                return;
            }
            var samples = sampleGroup.Samples;

            if (samples.Count < 2)
            {
                sampleGroup.Min               = samples[0];
                sampleGroup.Max               = samples[0];
                sampleGroup.Median            = samples[0];
                sampleGroup.Average           = samples[0];
                sampleGroup.Sum               = samples[0];
                sampleGroup.StandardDeviation = 0;
            }
            else
            {
                sampleGroup.Min               = Utils.Min(samples);
                sampleGroup.Max               = Utils.Max(samples);
                sampleGroup.Median            = Utils.GetMedianValue(samples);
                sampleGroup.Average           = Utils.Average(samples);
                sampleGroup.Sum               = Utils.Sum(samples);
                sampleGroup.StandardDeviation = Utils.GetStandardDeviation(samples, sampleGroup.Average);
            }
        }