private void UpdateBufferSizeStatistics(Type dtoType, int actualSize) { var targetValue = (int) (actualSize * 1.5 / 16 + 1) * 16;// pad to 16 if (BufferStatistics.TryGetValue(dtoType, out var statisticsValue)) { if (statisticsValue < targetValue) { BufferStatistics.TryUpdate(dtoType, targetValue, statisticsValue); } } else { BufferStatistics.TryAdd(dtoType, targetValue); } }
private int GetBufferSize(Type dtoType) { if (BufferStatistics.TryGetValue(dtoType, out var size)) return size; return _basePacketBufferSize; }