/// <summary>
 /// This is the default status of the stats.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(string.Format("InProgress={5} Processed={0} Errors={1} Average={2} Total={6} @ {3:F2}tps ({4:u})"
                          , mCurrent.Messages                          //0
                          , mTotalErrors                               //1
                          , StatsCounter.LargeTime(mCurrent.Average)   //2
                          , mCurrent.Tps                               //3
                          , mCurrent.Created                           //4
                          , mTotalMessagesIn - mCurrent.Messages       //5
                          , StatsCounter.LargeTime(mCurrent.Extent))); //6
 }
        /// <summary>
        /// This method archives the batch at a specified interval.
        /// </summary>
        /// <param name="batch"></param>
        protected virtual void BatchArchive(StatsCounter batch)
        {
            batch.Id = Interlocked.Increment(ref mBatchCount);
            mBatchHistory[batch.Id % mBatchHistory.LongLength] = batch;

            if (batch.Delta > 0 && (mBatchSlow == null || batch.Average > mBatchSlow.Average))
            {
                mBatchSlow = batch;
            }
            if (batch.Delta > 0 && (mBatchFast == null || batch.Average < mBatchFast.Average))
            {
                mBatchFast = batch;
            }
        }
        /// <summary>
        /// This is the default constructor.
        /// </summary>
        public StatsContainer(int batchHistoryCount = 15, int batchSize = 500)
        {
            if (batchHistoryCount < 0)
            {
                throw new ArgumentOutOfRangeException("batchHistoryCount", "batchHistoryCount cannot be less that zero");
            }
            if (batchSize <= 0)
            {
                throw new ArgumentOutOfRangeException("batchSize", "batchSize cannot zero or less");
            }

            mBatchHistory = new StatsCounter[batchHistoryCount];
            mBatchSize    = batchSize;
            mCurrent      = new StatsCounter();
            mBatch        = new StatsCounter(mBatchSize > 0 ? mBatchSize : 500);
        }