-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache current process object to avoid performance hit (#5597)
* Read working set from Environment in ProcessInfo since it has better performance. * Add unit test for ProcessInfo. * Remove OSSkipCondition tag from process info unit test since it's cross-platform. * Use Environment.WorkingSet in GetMemoryUsageInBytes.
- Loading branch information
Showing
3 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ies/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/ProcessInfoTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Interop; | ||
using Microsoft.TestUtilities; | ||
using Xunit; | ||
|
||
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test; | ||
|
||
/// <summary> | ||
/// Process Info Interop Tests. | ||
/// </summary> | ||
/// <remarks>These tests are added for coverage reasons, but the code doesn't have | ||
/// the necessary environment predictability to really test it.</remarks> | ||
public sealed class ProcessInfoTests | ||
{ | ||
[ConditionalFact] | ||
public void GetCurrentProcessMemoryUsage() | ||
{ | ||
var workingSet64 = new ProcessInfo().GetCurrentProcessMemoryUsage(); | ||
Assert.True(workingSet64 > 0); | ||
} | ||
} |