c# - BenchmarkDotNet is showing no console and hence no output - Stack Overflow

admin2025-04-16  5

I am using Lenovo T430, Windows 10, Visual Studio 2017, .NET 4.7.2, and BenchmarkDotNet 0.11.3.

I am seeing no console.

I am seeing no output.

What am I doing incorrectly?

using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

namespace BenchmarkTest
{
    public class BenchmarkSetup
    {
        private double num1;
        private double num2;

        [GlobalSetup]
        public void Setup()
        {
            num1 = 12345.6789;
            num2 = 98765.4321;
        }

        [Benchmark]
        public double Addition() => num1 + num2;

        [Benchmark]
        public double Subtraction() => num1 - num2;

        [Benchmark]
        public double Multiplication() => num1 * num2;

        [Benchmark]
        public double Division() => num1 / num2;
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            // Run the benchmark
            var summary = BenchmarkRunner.Run<BenchmarkSetup>();

            // Display completion message
            Console.WriteLine("Benchmark completed.");
            Console.ReadLine();
        }
    }
}

转载请注明原文地址:http://anycun.com/QandA/1744778032a87489.html