Skip to content

Commit 4f5496e

Browse files
authored
test: Tweak PerformanceMetrics tests for better CI stability (#3518)
1 parent 6adebe3 commit 4f5496e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries

tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/PerformanceMetrics.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ public static void Test(int countMaxWorkerThreads, int countMaxCompletionThreads
1919

2020
ThreadPool.SetMaxThreads(countMaxWorkerThreads, countMaxCompletionThreads);
2121

22+
// Induce Gen0-only collections BEFORE the agent starts. GCSamplerV2 reads
23+
// cumulative GC.CollectionCount() values, so these pre-agent collections
24+
// guarantee that CollectionCount(0) > CollectionCount(1) by the time the
25+
// first sample runs — regardless of when the sampler fires relative to
26+
// StartAgent(). V1 (EventListener-based) is unaffected since it only
27+
// captures events after the listener registers inside StartAgent().
28+
GC.Collect(0);
29+
GC.Collect(0);
30+
2231
StartAgent();
2332
}
2433

0 commit comments

Comments
 (0)