コード例 #1
0
        protected void StoreInSummarizeItem(MeterItem meterItem, int adjustedTail)
        {
            var newSummary = new SummerizedItem
            {
                TotalTimeStart = meterItem.Start,
                TotalTimeEnd   = meterItem.End,
                Count          = 1,
                MaxTime        = meterItem.Duration,
                MinTime        = meterItem.Duration,
                TotalTime      = meterItem.Duration,
                TotalCounter   = meterItem.Counter,
            };

            for (int i = 0; i < Buffer.Length; i++)
            {
                var oldVal = Interlocked.Exchange(ref Buffer[(adjustedTail + i) % Buffer.Length], null);
                if (oldVal != null)
                {
                    newSummary.TotalTimeStart = newSummary.TotalTimeStart > oldVal.Start ? oldVal.Start : newSummary.TotalTimeStart;
                    newSummary.TotalTimeEnd   = newSummary.TotalTimeEnd > oldVal.End ? newSummary.TotalTimeEnd : oldVal.End;
                    newSummary.Count++;
                    newSummary.MaxTime       = newSummary.MaxTime > oldVal.Duration ? newSummary.MaxTime : oldVal.Duration;
                    newSummary.MinTime       = newSummary.MinTime > oldVal.Duration ? oldVal.Duration : newSummary.MinTime;
                    newSummary.TotalCounter += oldVal.Counter;
                    newSummary.TotalTime    += oldVal.Duration;
                }
            }
            var increment = Interlocked.Increment(ref _summerizedPos);

            _summerizedBuffer[increment % _summerizedBuffer.Length] = newSummary;
        }
コード例 #2
0
        internal void Mark(long size, DateTime start, DateTime end, IoMetrics.MeterType type)
        {
            var meterItem = new MeterItem
            {
                Start = start,
                Size  = size,
                Type  = type,
                End   = end
            };

            var pos          = Interlocked.Increment(ref _bufferPos);
            var adjustedTail = pos % _buffer.Length;

            if (Interlocked.CompareExchange(ref _buffer[adjustedTail], meterItem, null) == null)
            {
                return;
            }

            var newSummary = new SummerizedItem
            {
                TotalTimeStart = meterItem.Start,
                TotalTimeEnd   = meterItem.End,
                Count          = 1,
                MaxTime        = meterItem.Duration,
                MinTime        = meterItem.Duration,
                TotalTime      = meterItem.Duration,
                TotalSize      = meterItem.Size,
                Type           = meterItem.Type
            };

            for (int i = 0; i < _buffer.Length; i++)
            {
                var oldVal = Interlocked.Exchange(ref _buffer[(adjustedTail + i) % _buffer.Length], null);
                if (oldVal != null)
                {
                    newSummary.TotalTimeStart = newSummary.TotalTimeStart > oldVal.Start ? oldVal.Start : newSummary.TotalTimeStart;
                    newSummary.TotalTimeEnd   = newSummary.TotalTimeEnd > oldVal.End ? newSummary.TotalTimeEnd : oldVal.End;
                    newSummary.Count++;
                    newSummary.MaxTime    = newSummary.MaxTime > oldVal.Duration ? newSummary.MaxTime : oldVal.Duration;
                    newSummary.MinTime    = newSummary.MinTime > oldVal.Duration ? oldVal.Duration : newSummary.MinTime;
                    newSummary.TotalSize += oldVal.Size;
                    newSummary.TotalTime += oldVal.Duration;
                }
            }
            var increment = Interlocked.Increment(ref _summerizedPos);

            _summerizedBuffer[increment % _summerizedBuffer.Length] = newSummary;
        }
コード例 #3
0
ファイル: IoMeterBuffer.cs プロジェクト: syrjgc11006/ravendb
 public IoMeterBuffer(int metricsBufferSize, int summaryBufferSize)
 {
     _buffer           = new MeterItem[metricsBufferSize];
     _summerizedBuffer = new SummerizedItem[summaryBufferSize];
 }
コード例 #4
0
ファイル: IoMeterBuffer.cs プロジェクト: syrjgc11006/ravendb
        internal void Mark(ref DurationMeasurement item)
        {
            var meterItem = new MeterItem
            {
                Start          = item.Start,
                Size           = item.Size,
                FileSize       = item.FileSize,
                Type           = item.Type,
                End            = item.End,
                CompressedSize = item.CompressedSize,
                Acceleration   = item.Acceleration,
            };

            item.OnFileChange?.Invoke(meterItem);

            var pos          = Interlocked.Increment(ref _bufferPos);
            var adjustedTail = pos % _buffer.Length;

            if (Interlocked.CompareExchange(ref _buffer[adjustedTail], meterItem, null) == null)
            {
                return;
            }

            var newSummary = new SummerizedItem
            {
                TotalTimeStart      = meterItem.Start,
                TotalTimeEnd        = meterItem.End,
                Count               = 1,
                TotalCompressedSize = meterItem.CompressedSize,
                MaxAcceleration     = meterItem.Acceleration,
                MinAcceleration     = meterItem.Acceleration,
                MaxTime             = meterItem.Duration,
                MinTime             = meterItem.Duration,
                TotalTime           = meterItem.Duration,
                TotalSize           = meterItem.Size,
                TotalFileSize       = meterItem.FileSize,
                Type = meterItem.Type
            };

            for (int i = 0; i < _buffer.Length; i++)
            {
                var oldVal = Interlocked.Exchange(ref _buffer[(adjustedTail + i) % _buffer.Length], null);
                if (oldVal != null)
                {
                    newSummary.TotalTimeStart = newSummary.TotalTimeStart > oldVal.Start ? oldVal.Start : newSummary.TotalTimeStart;
                    newSummary.TotalTimeEnd   = newSummary.TotalTimeEnd > oldVal.End ? newSummary.TotalTimeEnd : oldVal.End;
                    newSummary.Count++;
                    newSummary.MaxAcceleration      = Math.Max(newSummary.MaxAcceleration, oldVal.Acceleration);
                    newSummary.MinAcceleration      = Math.Min(newSummary.MinAcceleration, oldVal.Acceleration);
                    newSummary.MaxTime              = newSummary.MaxTime > oldVal.Duration ? newSummary.MaxTime : oldVal.Duration;
                    newSummary.MinTime              = newSummary.MinTime > oldVal.Duration ? oldVal.Duration : newSummary.MinTime;
                    newSummary.TotalSize           += oldVal.Size;
                    newSummary.TotalCompressedSize += oldVal.CompressedSize;
                    newSummary.TotalFileSize        = oldVal.FileSize; // take last size to history
                    newSummary.TotalTime           += oldVal.Duration;
                }
            }
            var increment = Interlocked.Increment(ref _summerizedPos);

            _summerizedBuffer[increment % _summerizedBuffer.Length] = newSummary;
        }