diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index ccf3d3f6741c1..813998ba6f9f0 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -218,6 +218,7 @@ + @@ -1087,8 +1088,8 @@ - - + + @@ -1123,6 +1124,7 @@ + @@ -1247,7 +1249,7 @@ - + @@ -1273,6 +1275,7 @@ + @@ -1368,8 +1371,6 @@ - - diff --git a/src/System.Private.CoreLib/shared/System/HighPerformanceCounter.Unix.cs b/src/System.Private.CoreLib/shared/System/HighPerformanceCounter.Unix.cs deleted file mode 100644 index cfe582ddfdc73..0000000000000 --- a/src/System.Private.CoreLib/shared/System/HighPerformanceCounter.Unix.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; - -namespace System -{ - internal static class HighPerformanceCounter - { - public static ulong TickCount => Interop.Sys.GetTimestamp(); - - // Cache the frequency on the managed side to avoid the cost of P/Invoke on every access to Frequency - public static ulong Frequency { get; } = Interop.Sys.GetTimestampResolution(); - } -} diff --git a/src/System.Private.CoreLib/shared/System/HighPerformanceCounter.Windows.cs b/src/System.Private.CoreLib/shared/System/HighPerformanceCounter.Windows.cs deleted file mode 100644 index 1bd40ab843ac8..0000000000000 --- a/src/System.Private.CoreLib/shared/System/HighPerformanceCounter.Windows.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System -{ - internal static unsafe class HighPerformanceCounter - { - public static ulong TickCount - { - get - { - long counter; - Interop.Kernel32.QueryPerformanceCounter(&counter); - return (ulong)counter; - } - } - - public static ulong Frequency { get; } = GetFrequency(); - - private static ulong GetFrequency() - { - long frequency; - Interop.Kernel32.QueryPerformanceFrequency(&frequency); - return (ulong)frequency; - } - } -} diff --git a/src/System.Private.CoreLib/shared/System/Threading/PortableThreadPool.cs b/src/System.Private.CoreLib/shared/System/Threading/PortableThreadPool.cs index aad21dfa5e384..3ea1c15b9b321 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/PortableThreadPool.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/PortableThreadPool.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Diagnostics; using System.Runtime.InteropServices; namespace System.Threading @@ -57,7 +58,7 @@ private struct CacheLineSeparated } private CacheLineSeparated _separated; - private ulong _currentSampleStartTime; + private long _currentSampleStartTime; private readonly ThreadInt64PersistentCounter _completionCounter = new ThreadInt64PersistentCounter(); private int _threadAdjustmentIntervalMs; @@ -225,9 +226,9 @@ private void AdjustMaxWorkersActive() int currentTicks = Environment.TickCount; int totalNumCompletions = (int)_completionCounter.Count; int numCompletions = totalNumCompletions - _separated.priorCompletionCount; - ulong startTime = _currentSampleStartTime; - ulong endTime = HighPerformanceCounter.TickCount; - ulong freq = HighPerformanceCounter.Frequency; + long startTime = _currentSampleStartTime; + long endTime = Stopwatch.GetTimestamp(); + long freq = Stopwatch.Frequency; double elapsedSeconds = (double)(endTime - startTime) / freq;