AppDomain.Unix.cs 867 B

1234567891011121314151617181920212223242526
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. namespace System
  5. {
  6. public sealed partial class AppDomain
  7. {
  8. public TimeSpan MonitoringTotalProcessorTime
  9. {
  10. get
  11. {
  12. Interop.Sys.ProcessCpuInformation cpuInfo = default;
  13. Interop.Sys.GetCpuUtilization(ref cpuInfo);
  14. ulong userTime100Nanoseconds = cpuInfo.lastRecordedUserTime / 100; // nanoseconds to 100-nanoseconds
  15. if (userTime100Nanoseconds > long.MaxValue)
  16. {
  17. userTime100Nanoseconds = long.MaxValue;
  18. }
  19. return new TimeSpan((long)userTime100Nanoseconds);
  20. }
  21. }
  22. }
  23. }