private void UpdatePerfCounters() { if (Process.HasExited) { return; } var buffer = new Process.ProcessResourceUsage(); // get processor times for the root process itself int errCode = Interop.Unix.Process.GetProcessResourceUsage(ProcessId, ref buffer, includeChildProcesses: false); if (errCode == 0) { m_perfAggregator.KernelTimeMs.RegisterSample(buffer.SystemTimeNs / 1000); m_perfAggregator.UserTimeMs.RegisterSample(buffer.UserTimeNs / 1000); } // get processor times for the process tree errCode = Interop.Unix.Process.GetProcessResourceUsage(ProcessId, ref buffer, includeChildProcesses: true); if (errCode == 0) { m_perfAggregator.JobKernelTimeMs.RegisterSample(buffer.SystemTimeNs / 1000); m_perfAggregator.JobUserTimeMs.RegisterSample(buffer.UserTimeNs / 1000); m_perfAggregator.DiskBytesRead.RegisterSample(buffer.DiskBytesRead); m_perfAggregator.DiskBytesWritten.RegisterSample(buffer.DiskBytesWritten); } // get memory usage for the process tree m_perfAggregator.PeakMemoryBytes.RegisterSample(Dispatch.GetActivePeakWorkingSet(default, ProcessId));
private static void UpdatePerfCounters(object state) { var proc = (SandboxedProcessMac)state; var buffer = new Process.ProcessResourceUsage(); // get processor times for the root process itself int errCode = Interop.MacOS.Process.GetProcessResourceUsage(proc.ProcessId, ref buffer, includeChildProcesses: false); if (errCode == 0) { proc.m_perfAggregator.KernelTimeMs.RegisterSample(buffer.SystemTimeNs / 1000); proc.m_perfAggregator.UserTimeMs.RegisterSample(buffer.UserTimeNs / 1000); } // get processor times for the process tree errCode = Interop.MacOS.Process.GetProcessResourceUsage(proc.ProcessId, ref buffer, includeChildProcesses: true); if (errCode == 0) { proc.m_perfAggregator.JobKernelTimeMs.RegisterSample(buffer.SystemTimeNs / 1000); proc.m_perfAggregator.JobUserTimeMs.RegisterSample(buffer.UserTimeNs / 1000); } // get memory usage for the process tree proc.m_perfAggregator.PeakMemoryBytes.RegisterSample(Dispatch.GetActivePeakMemoryUsage(default, proc.ProcessId));