using System;
using System.Collections.Generic;
using System.Linq;

namespace DatabaseEditor.BL
{
    public class Measurer
    {
        private readonly List<TimeSpan> _times = new List<TimeSpan>();

        public void AddTime(TimeSpan time)
        {
            _times.Add(time);
        }

        public TimeSpan AverageTime()
        {
            if (!_times.Any()) return TimeSpan.Zero;
            return TimeSpan.FromTicks(Convert.ToInt64(_times.Average(t => t.Ticks)));
        }

        public TimeSpan MaxTime => _times.Max();
        public TimeSpan MinTime => _times.Min();
    }
}
