Ejemplo n.º 1
0
        protected virtual void ComputeAverage(StatisticsSet statistics)
        {
            foreach (IStatistics field in statistics.Fields)
            {
                IAverageStatistics average = field.NewAverageStatistics();

                if (average == null)
                {
                    continue;
                }

                object key = StatisticsHelper.ResolveID(average);
                if (this[key] != null)
                {
                    average = this[key] as IAverageStatistics;
                    Debug.Assert(average != null);
                }
                else
                {
                    AddField(average);
                }

                if (field is Statistics <int> )
                {
                    average.AddSample(((Statistics <int>)field).Value);
                }
                else if (field is Statistics <uint> )
                {
                    average.AddSample(((Statistics <uint>)field).Value);
                }
                else if (field is Statistics <long> )
                {
                    //sum += ((Statistics<long>)field).Value;
                    average.AddSample(((Statistics <long>)field).Value);
                }
                else if (field is Statistics <ulong> )
                {
                    average.AddSample(((Statistics <ulong>)field).Value);
                }
                else if (field is Statistics <double> )
                {
                    average.AddSample(((Statistics <double>)field).Value);
                }
                else if (field is TimeSpanStatistics)
                {
                    TimeSpanStatistics stat = field as TimeSpanStatistics;
                    if (stat.IsSet)
                    {
                        average.AddSample(((TimeSpanStatistics)field).Value);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a sample to the <see cref="AverageStatistics{T}.Samples"/> list.
 /// </summary>
 /// <typeparam name="TSample">Type of the sample value to be inserted</typeparam>
 /// <param name="sample"></param>
 public override void AddSample <TSample>(TSample sample)
 {
     if (sample is TimeSpan)
     {
         TimeSpan ts = (TimeSpan)(object)sample;
         Samples.Add(new TimeSpan(ts.Ticks));
         NewSamepleAdded = true;
     }
     else if (sample is TimeSpanStatistics)
     {
         TimeSpanStatistics stat = (TimeSpanStatistics)(object)sample;
         Samples.Add(stat.Value);
         NewSamepleAdded = true;
     }
     else
     {
         base.AddSample(sample);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a copy of the orginal <see cref="TimeSpanStatistics"/> object.
 /// </summary>
 /// <param name="copy"></param>
 public TimeSpanStatistics(TimeSpanStatistics copy)
     : base(copy)
 {
 }
Ejemplo n.º 4
0
        public override object Clone()
        {
            TimeSpanStatistics copy = new TimeSpanStatistics(this);

            return(copy);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds a duration to the current <see cref="TimeSpanStatistics"/>.
 /// </summary>
 /// <param name="duration">The duration </param>
 /// <remarks>
 /// Duration set using <see cref="Subtract(TimeSpanStatistics)"/> will
 /// be lost if <see cref="Start"/> and <see cref="End"/> are called.
 /// </remarks>
 public void Subtract(TimeSpanStatistics duration)
 {
     Platform.CheckForNullReference(duration, "duration");
     Value = Value.Subtract(duration.Value);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a copy of the original <see cref="AverageTimeSpanStatistics"/> object.
 /// </summary>
 /// <param name="source"></param>
 public AverageTimeSpanStatistics(TimeSpanStatistics source)
     : base(source)
 {
 }