MeasureMap 3.0.0-RC48

This is a prerelease version of MeasureMap.
dotnet add package MeasureMap --version 3.0.0-RC48
                    
NuGet\Install-Package MeasureMap -Version 3.0.0-RC48
                    
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="MeasureMap" Version="3.0.0-RC48" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MeasureMap" Version="3.0.0-RC48" />
                    
Directory.Packages.props
<PackageReference Include="MeasureMap" />
                    
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 MeasureMap --version 3.0.0-RC48
                    
#r "nuget: MeasureMap, 3.0.0-RC48"
                    
#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 MeasureMap@3.0.0-RC48
                    
#: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=MeasureMap&version=3.0.0-RC48&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MeasureMap&version=3.0.0-RC48&prerelease
                    
Install as a Cake Tool

MeasureMap

Profiling and Benchmarking .NET Code made simple
MeasureMap allows profiling and benchmarking from simple code fragments to full applications.

Visit https://wickedflame.github.io/MeasureMap/ for the full documentation.

MeasureMap uses the builder pattern and a fluent API to make profiling or benchmarking as simple as possible.

Profiling

The Builder for profiling is initiated with the ProfilerSession when running the StartSession method.

var result = ProfilerSession.StartSession()
	.Task(() => 
	{
		// This represents the Task that needs testint
		System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.001));
	})
	.SetIterations(200)
	.Assert(pr => pr.Iterations.Count() == 1)
	.RunSession();

result.Trace();

Assert.IsTrue(result.AverageMilliseconds < 20);

RunSession executes the profiler for the registered Task.

Benchmarking

Benchmarks are basically just multiple Profiler-Sessions that are run in one Session.
The Benchmarks are registered to and executed by the BenchmarkRunner.

Benchmarks can be run in two ways

  • FluentAPI
  • Attributes

FluentAPI

var sha256 = SHA256.Create();
var md5 = MD5.Create();

var data = new byte[10000];
new Random(42).NextBytes(data);

var runner = new BenchmarkRunner();
runner.SetIterations(10);
runner.Task("sha256", () => sha256.ComputeHash(data));
runner.Task("md5", () => md5.ComputeHash(data));

var result = runner.RunSessions();

result.Trace();

Attributes

[Iterations(10)]
[Threads(10)]
//[Duration(10)]
[RunWarmup(false)]
public class  WorkflowBenchmark
{
    private readonly SHA256 _sha256;
    private readonly MD5 _md5;
    private readonly byte[] _data;
    
    public WorkflowBenchmark()
    {
        _sha256 = SHA256.Create();
        _md5 = MD5.Create();

        _data = new byte[10000];
        new Random(42).NextBytes(_data);
    }
    
    [OnStartPipeline]
    public void Setup()
    {
    }

    [OnEndPipeline]
    public void End()
    {
    }

    [Benchmark]
    public void sha256()
    {
        // Simulate some work
        _sha256.ComputeHash(_data);
    }

    [Benchmark]
    public void md5(IExecutionContext ctx)
    {
        // Simulate some work
        _md5.ComputeHash(_data);
    }
}
[Test]
public void WorkflowTest_Benchmark()
{
    var runner = new BenchmarkRunner();
    var result = runner.RunSession<WorkflowBenchmark>();
    result.Trace();
}

Tracing the Result

The result is by default traced as Markdown

### MeasureMap Benchmark
 Iterations:		10
#### Summary
| Name   | Avg Time         | Avg Ticks | Total            | Fastest | Slowest | Memory Increase |
|------- |----------------: |---------: |----------------: |-------: |-------: |---------------: |
| sha256 | 00:00:00.0000924 | 924       | 00:00:00.0009243 | 776     | 1471    | 1392            |
| md5    | 00:00:00.0000485 | 485       | 00:00:00.0004858 | 409     | 534     | 1392            |

Workflow

The Workflow of MeasureMap is setup in three stacks or pipelines. The stack is made up of an execution chain following the Chain of Responsibility pattern. Each item in the pipeline is connected to the next in the chain.
The items in each stack are processed one after another. Handlers have logic that can be executed before or after the next handler in the chain is processed.

SessionStack (ISessionMiddleware)

The SessionStack is run once per Session

  • ElapsedTimeSessionHandler
  • PreExecutionSessionHandler
  • WarmupSessionHandler
  • BasicSessionHandler / MainThreadSessionHandler / MultyThreadSessionHandler

ContextStack (IContextMiddleware)

The ContextStack is run once per Thread. The DefaultContextStackBuilder creates a new instance of the stack for each Thread.

  • OnStartPipelineContextHandler
  • OnEndPipelineContextHandler
  • ProcessDataContextHandler
  • WorkerContextHandler
IterationStack (IIterationMiddleware)

The IterationStack is run once for every Iteration.

  • ProcessDataTaskHandler (ITaskMiddleware)
  • MemoryCollectionTaskHandler (ITaskMiddleware)
  • ElapsedTimeTaskHandler (ITaskMiddleware)
  • _task (ITask)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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
3.0.0-RC48 173 8/27/2025
3.0.0-RC22 216 8/7/2025
2.4.0 255 6/5/2025
2.3.2 168 5/6/2025
2.3.1 129 5/2/2025
2.2.1 1,037 1/30/2023
2.2.0 725 12/19/2022
2.1.0 794 10/31/2022
2.0.2 785 10/20/2022
2.0.1 810 9/28/2022
2.0.0 863 9/5/2022
1.7.0 993 2/22/2022
1.6.2 979 3/31/2021
1.6.1 874 3/23/2021
1.6.0 1,087 5/19/2020
1.5.2 1,012 5/6/2020
1.5.1 1,003 4/21/2020
1.5.0 998 4/20/2020
1.4.0.17 1,159 11/29/2019
1.3.0 996 11/27/2019
1.2.2 1,721 6/12/2018
1.2.1 1,758 4/25/2018
1.2.0 1,579 4/19/2018
1.1.0 1,735 4/17/2018
1.0.0 1,550 4/11/2018
0.2.0 1,563 4/11/2018