Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ConcurrentDictionary in runtimecounters test #105520

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions src/tests/tracing/eventcounter/runtimecounters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Threading;
Expand All @@ -15,35 +16,38 @@ public class RuntimeCounterListener : EventListener
{
public RuntimeCounterListener()
{
observedRuntimeCounters = new Dictionary<string, bool>() {
{ "cpu-usage" , false },
{ "working-set", false },
{ "gc-heap-size", false },
{ "gen-0-gc-count", false },
{ "gen-1-gc-count", false },
{ "gen-2-gc-count", false },
{ "threadpool-thread-count", false },
{ "monitor-lock-contention-count", false },
{ "threadpool-queue-length", false },
{ "threadpool-completed-items-count", false },
{ "alloc-rate", false },
{ "active-timer-count", false },
{ "gc-fragmentation", false },
{ "gc-committed", false },
{ "exception-count", false },
{ "time-in-gc", false },
{ "gen-0-size", false },
{ "gen-1-size", false },
{ "gen-2-size", false },
{ "loh-size", false },
{ "poh-size", false },
{ "assembly-count", false },
{ "il-bytes-jitted", false },
{ "methods-jitted-count", false },
{ "time-in-jit", false }
};
observedRuntimeCounters = new ConcurrentDictionary<string, bool>();
foreach (string counter in new string[] {
"cpu-usage",
"working-set",
"gc-heap-size",
"gen-0-gc-count",
"gen-1-gc-count",
"gen-2-gc-count",
"threadpool-thread-count",
"monitor-lock-contention-count",
"threadpool-queue-length",
"threadpool-completed-items-count",
"alloc-rate",
"active-timer-count",
"gc-fragmentation",
"gc-committed",
"exception-count",
"time-in-gc",
"gen-0-size",
"gen-1-size",
"gen-2-size",
"loh-size",
"poh-size",
"assembly-count",
"il-bytes-jitted",
"methods-jitted-count",
"time-in-jit" })
{
observedRuntimeCounters[counter] = false;
}
}
private Dictionary<string, bool> observedRuntimeCounters;
private ConcurrentDictionary<string, bool> observedRuntimeCounters;

protected override void OnEventSourceCreated(EventSource source)
{
Expand All @@ -59,7 +63,6 @@ protected override void OnEventSourceCreated(EventSource source)

protected override void OnEventWritten(EventWrittenEventArgs eventData)
{

for (int i = 0; i < eventData.Payload.Count; i++)
{
IDictionary<string, object> eventPayload = eventData.Payload[i] as IDictionary<string, object>;
Expand Down
Loading