19 lines
567 B
C#
19 lines
567 B
C#
using System.Collections.Concurrent;
|
|
using System.Numerics;
|
|
|
|
namespace SafelyYou;
|
|
|
|
public sealed class UploadTimes
|
|
{
|
|
private readonly ConcurrentDictionary<DeviceId, (BigInteger TotalUploadTime, int UploadCounts)> _uploadHistories = new();
|
|
|
|
public void Add(DeviceId deviceId, BigInteger uploadTimeNanos)
|
|
{
|
|
if (!_uploadHistories.TryGetValue(deviceId, out var history))
|
|
{
|
|
history = (BigInteger.Zero, 0);
|
|
}
|
|
|
|
_uploadHistories[deviceId] = (history.TotalUploadTime + uploadTimeNanos, history.UploadCounts + 1);
|
|
}
|
|
} |