예제 #1
0
        // Token: 0x0600729A RID: 29338 RVA: 0x0017B664 File Offset: 0x00179864
        private static bool InternalCalculateCPUUsagePercentage(IntPtr process, ref DateTime lastUpdatedTime, ref long lastCPU, out float cpuUsage)
        {
            cpuUsage = 0f;
            long num = 0L;

            if (!CPUUsage.InternalGetCurrentCPU(process, ref num))
            {
                return(false);
            }
            DateTime utcNow       = DateTime.UtcNow;
            long     num2         = num - lastCPU;
            double   totalSeconds = (utcNow - lastUpdatedTime).TotalSeconds;

            if (totalSeconds > 0.0)
            {
                cpuUsage = (float)((double)num2 * 1E-05 / (totalSeconds * (double)CPUUsage.processorCount));
                if (cpuUsage > 100f)
                {
                    cpuUsage = 100f;
                }
                lastUpdatedTime = utcNow;
                lastCPU         = num;
            }
            return(true);
        }
예제 #2
0
 // Token: 0x06007299 RID: 29337 RVA: 0x0017B641 File Offset: 0x00179841
 internal static bool GetCurrentCPU(IntPtr process, ref long cpuTime)
 {
     if (process == IntPtr.Zero)
     {
         throw new ArgumentNullException("process");
     }
     return(CPUUsage.InternalGetCurrentCPU(process, ref cpuTime));
 }
예제 #3
0
 // Token: 0x06007298 RID: 29336 RVA: 0x0017B634 File Offset: 0x00179834
 internal static bool GetCurrentCPU(ref long cpuTime)
 {
     return(CPUUsage.InternalGetCurrentCPU(IntPtr.Zero, ref cpuTime));
 }