2025-07-04 00:04:51 +03:00
|
|
|
|
/* This software is licensed by the MIT License, see LICENSE file */
|
|
|
|
|
/* Copyright © 2024-2025 Gregory Lirent */
|
2025-07-03 15:22:40 +03:00
|
|
|
|
|
|
|
|
|
using WebmrAPI.Utils;
|
|
|
|
|
|
|
|
|
|
namespace WebmrAPI.Services.Scanners
|
|
|
|
|
{
|
|
|
|
|
public abstract class AbstractCpuScanner<T> : AbstractScanner<T> where T : new()
|
|
|
|
|
{
|
|
|
|
|
public static double CalcCpuUsage(double pTime, double elapsed)
|
|
|
|
|
{
|
|
|
|
|
double cpuUsage = 0;
|
|
|
|
|
if (elapsed > 0)
|
|
|
|
|
{
|
|
|
|
|
cpuUsage = (pTime / elapsed) / Environment.ProcessorCount * 100.0;
|
|
|
|
|
if (cpuUsage > 100.0) cpuUsage = 100.0;
|
|
|
|
|
}
|
|
|
|
|
return cpuUsage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AbstractCpuScanner(IScanProvider scanner, LazyConcurrentContainer<T> container)
|
|
|
|
|
: base(scanner, container) { }
|
|
|
|
|
}
|
|
|
|
|
}
|