From e801bba96932171d53e3812b7ae6161ec99d86be Mon Sep 17 00:00:00 2001 From: Ikiru Yoshizaki <3856350+guitarrapc@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:43:24 +0900 Subject: [PATCH] chore: benchmark occasionally failed to get ProcessorCount --- perf/BenchmarkApp/PerformanceTest.Client/Program.cs | 4 ++-- .../Reporting/HardwarePerformanceReporter.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/perf/BenchmarkApp/PerformanceTest.Client/Program.cs b/perf/BenchmarkApp/PerformanceTest.Client/Program.cs index c075f0d33..14f8b28af 100644 --- a/perf/BenchmarkApp/PerformanceTest.Client/Program.cs +++ b/perf/BenchmarkApp/PerformanceTest.Client/Program.cs @@ -229,7 +229,7 @@ async Task 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())); } @@ -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(); } diff --git a/perf/BenchmarkApp/PerformanceTest.Shared/Reporting/HardwarePerformanceReporter.cs b/perf/BenchmarkApp/PerformanceTest.Shared/Reporting/HardwarePerformanceReporter.cs index 5a0e51248..5d93ce26d 100644 --- a/perf/BenchmarkApp/PerformanceTest.Shared/Reporting/HardwarePerformanceReporter.cs +++ b/perf/BenchmarkApp/PerformanceTest.Shared/Reporting/HardwarePerformanceReporter.cs @@ -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(); memoryUsages = new ConcurrentBag(); cancellationTokenSource = new CancellationTokenSource();