Skip to content

Commit

Permalink
chore: benchmark occasionally failed to get ProcessorCount
Browse files Browse the repository at this point in the history
  • Loading branch information
guitarrapc committed Sep 17, 2024
1 parent 4478fec commit e801bba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions perf/BenchmarkApp/PerformanceTest.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async Task<PerformanceResult> RunScenarioAsync(ScenarioType scenario, ScenarioCo
await controlService.CreateMemoryProfilerSnapshotAsync("Completed");

WriteLog("Cleaning up...");
foreach (var s in scenarios.Chunk(Environment.ProcessorCount))
foreach (var s in scenarios.Chunk(ApplicationInformation.Current.ProcessorCount))
{
await Task.WhenAll(s.Select(x => x.CompleteAsync()));
}
Expand Down Expand Up @@ -272,7 +272,7 @@ void PrintStartupInformation(TextWriter? writer = null)
writer.WriteLine($"{nameof(RuntimeInformation.OSArchitecture)}: {ApplicationInformation.Current.OSArchitecture}");
writer.WriteLine($"{nameof(RuntimeInformation.ProcessArchitecture)}: {ApplicationInformation.Current.ProcessArchitecture}");
writer.WriteLine($"{nameof(GCSettings.IsServerGC)}: {ApplicationInformation.Current.IsServerGC}");
writer.WriteLine($"{nameof(Environment.ProcessorCount)}: {ApplicationInformation.Current.ProcessorCount}");
writer.WriteLine($"{nameof(ApplicationInformation.Current.ProcessorCount)}: {ApplicationInformation.Current.ProcessorCount}");
writer.WriteLine($"{nameof(Debugger)}.{nameof(Debugger.IsAttached)}: {ApplicationInformation.Current.IsAttached}");
writer.WriteLine();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public HardwarePerformanceReporter(TimeSpan samplingInterval)
this.samplingInterval = samplingInterval;
this.timeProvider = SystemTimeProvider.TimeProvider;
currentProcess = Process.GetCurrentProcess();
cpuCores = Environment.ProcessorCount;
cpuCores = ApplicationInformation.Current.ProcessorCount;
cpuUsages = new ConcurrentBag<double>();
memoryUsages = new ConcurrentBag<double>();
cancellationTokenSource = new CancellationTokenSource();
Expand Down

0 comments on commit e801bba

Please sign in to comment.