akanse.PathBench 1.0.0

dotnet add package akanse.PathBench --version 1.0.0
                    
NuGet\Install-Package akanse.PathBench -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="akanse.PathBench" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="akanse.PathBench" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="akanse.PathBench" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add akanse.PathBench --version 1.0.0
                    
#r "nuget: akanse.PathBench, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package akanse.PathBench@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=akanse.PathBench&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=akanse.PathBench&version=1.0.0
                    
Install as a Cake Tool

PathBench

Code path performance monitoring tool.


Features

PathBench is a tool that measures method execution time to identify performance bottlenecks. It provides the following features:

  • Method execution time statistics: Measures method execution times and provides statistical information such as the mean, standard deviation, minimum, and maximum.
  • Checkpoint recording: Allows you to set checkpoints at arbitrary locations within a method and measure the execution time between checkpoints.
  • Result visualization: Outputs measurement results in Graphviz format and visualizes them as a directed graph between checkpoints.

Usage

  1. Installation: Add PathBench to your project from NuGet.
  2. Code changes
    1. Create a CodePathCounter instance in the class that contains the method you want to monitor.
    2. At the beginning of the monitored method, call counter.StartMeasurement() to create a measurement instance and start the measurement.
    3. Dispose the measurement instance to end the measurement.
    4. Call the CreateProfileReports() method on the CodePathCounter instance to produce measurement report instances.
    5. Pass the measurement report instances to an appropriate formatter to output the results.
using PathBench;

invokeTest();

static void invokeTest()
{
    for (var i = 0; i < 1000; ++i)
    {
        SampleClass.SimulatedWork(i);
    }

    var reports = SampleClass.Profiler.CreateProfileReports();
    var sw = new StringWriter();
    MethodProfileReportFormatter.DefaultGraphvizStyle.Format(
        reports[nameof(SampleClass.SimulatedWork)],
        writer: sw);
    Console.WriteLine(sw.ToString());
}

static class SampleClass
{
    public static readonly CodePathProfiler Profiler = CodePathProfiler.Create();

    public static void SimulatedWork(int seed)
    {
        using var counter = Profiler.StartMeasurement(argumentsExpressionProvider: $"seed={seed}");
        if (seed % 2 == 0)
        {
            counter.MarkCheckpoint("EvenSeed");
            Wait(2);
        }
        else
        {
            counter.MarkCheckpoint("OddSeed");
            Wait(0);
        }
        for (var i = 0; i < seed; ++i)
        {
            counter.MarkCheckpoint("LoopBegin", i);
            if (seed % 3 == 0)
            {
                counter.MarkCheckpoint("DivisibleBy3");
                Wait(3);
            }
            if (seed % 5 == 0)
            {
                counter.MarkCheckpoint("DivisibleBy5");
                Wait(5);
            }
            if (seed % 7 == 0)
            {
                counter.MarkCheckpoint("DivisibleBy7");
                Wait(7);
            }
            counter.MarkCheckpoint("LoopEnd");
        }
    }

    private static void Wait(int value)
    {
        Thread.SpinWait(value * 100);
    }
}

graphviz sample

Release Notes

v1.0.0

  • First release
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 84 2/17/2026