Replace const Hundred with One

This commit is contained in:
Evgenii Fedorov 2024-10-09 09:32:02 +02:00
Родитель 6b3b13efcd
Коммит 878b0cc9b4
2 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows;
internal sealed class WindowsContainerSnapshotProvider : ISnapshotProvider
{
private const double Hundred = 100.0d;
private const double One = 1.0d;
private readonly Lazy<MEMORYSTATUSEX> _memoryStatus;
@ -195,7 +195,7 @@ internal sealed class WindowsContainerSnapshotProvider : ISnapshotProvider
{
if (now >= _refreshAfterMemory)
{
_memoryPercentage = Math.Min(Hundred, memoryUsage / _memoryLimit);
_memoryPercentage = Math.Min(One, memoryUsage / _memoryLimit);
_refreshAfterMemory = now.Add(_memoryRefreshInterval);
}
@ -229,7 +229,7 @@ internal sealed class WindowsContainerSnapshotProvider : ISnapshotProvider
var timeTickDelta = (now.Ticks - _oldCpuTimeTicks) * _cpuLimit;
if (usageTickDelta > 0 && timeTickDelta > 0)
{
_cpuPercentage = Math.Min(Hundred, usageTickDelta / timeTickDelta);
_cpuPercentage = Math.Min(One, usageTickDelta / timeTickDelta);
Log.CpuContainerUsageData(
_logger, basicAccountingInfo.TotalKernelTime, basicAccountingInfo.TotalUserTime, _oldCpuUsageTicks, timeTickDelta, _cpuLimit, _cpuPercentage);

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows;
internal sealed class WindowsSnapshotProvider : ISnapshotProvider
{
private const double Hundred = 100.0d;
private const double One = 1.0d;
public SystemResources Resources { get; }
@ -136,7 +136,7 @@ internal sealed class WindowsSnapshotProvider : ISnapshotProvider
{
if (now >= _refreshAfterMemory)
{
_memoryPercentage = Math.Min(Hundred, currentMemoryUsage / _totalMemory);
_memoryPercentage = Math.Min(One, currentMemoryUsage / _totalMemory);
_refreshAfterMemory = now.Add(_memoryRefreshInterval);
}
@ -168,7 +168,7 @@ internal sealed class WindowsSnapshotProvider : ISnapshotProvider
var timeTickDelta = (now.Ticks - _oldCpuTimeTicks) * _cpuUnits;
if (usageTickDelta > 0 && timeTickDelta > 0)
{
_cpuPercentage = Math.Min(Hundred, usageTickDelta / (double)timeTickDelta);
_cpuPercentage = Math.Min(One, usageTickDelta / (double)timeTickDelta);
Log.CpuUsageData(_logger, currentCpuTicks, _oldCpuUsageTicks, timeTickDelta, _cpuUnits, _cpuPercentage);