From b4958cd05efb91b2066f2edca9a8a2dd54674607 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 5 Nov 2026 12:03:08 +0900 Subject: [PATCH] chore: re-enable vs-diagnoser package --- .../BenchmarkDotNet.Samples.csproj | 2 ++ .../IntroVisualStudioDiagnoser.cs | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 samples/BenchmarkDotNet.Samples/IntroVisualStudioDiagnoser.cs diff --git a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj index b0a2c2c5a4..b5f087de5d 100644 --- a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj +++ b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj @@ -25,6 +25,8 @@ + + diff --git a/samples/BenchmarkDotNet.Samples/IntroVisualStudioDiagnoser.cs b/samples/BenchmarkDotNet.Samples/IntroVisualStudioDiagnoser.cs new file mode 100644 index 0000000000..0ac42df464 --- /dev/null +++ b/samples/BenchmarkDotNet.Samples/IntroVisualStudioDiagnoser.cs @@ -0,0 +1,21 @@ +using BenchmarkDotNet.Attributes; +using Microsoft.VSDiagnostics; + +namespace BenchmarkDotNet.Samples; + +// Enables profiling with the CPU Usage tool +// See: https://learn.microsoft.com/visualstudio/profiling/profiling-with-benchmark-dotnet +[CPUUsageDiagnoser] +public class IntroVisualStudioProfiler +{ + private readonly Random rand = new Random(42); + + [Benchmark] + public void BurnCPU() + { + for (int i = 0; i < 100000; ++i) + { + rand.Next(1, 100); + } + } +}