BenchmarkLite 1.0.2
dotnet add package BenchmarkLite --version 1.0.2
NuGet\Install-Package BenchmarkLite -Version 1.0.2
<PackageReference Include="BenchmarkLite" Version="1.0.2" />
<PackageVersion Include="BenchmarkLite" Version="1.0.2" />
<PackageReference Include="BenchmarkLite" />
paket add BenchmarkLite --version 1.0.2
#r "nuget: BenchmarkLite, 1.0.2"
#:package BenchmarkLite@1.0.2
#addin nuget:?package=BenchmarkLite&version=1.0.2
#tool nuget:?package=BenchmarkLite&version=1.0.2
A lightweight and simple benchmark tool.
Learn more about Target Frameworks and .NET Standard.
This package has 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 |
---|
Example:
using System;
using System.Threading;
public class BenchmarkLiteDemo
{
public static void Run()
{
var oRandom = new Random();
BenchmarkLite.Instance
.Title("Benchmark 1")
.Add(() =>
{
Thread.Sleep(oRandom.Next(10));
})
.Add(() =>
{
Thread.Sleep(oRandom.Next(10));
})
.Add((x) =>
{
Console.Write($"{x} \r");
Thread.Sleep(oRandom.Next(Math.Min(x, 10)));
})
.Add((x) =>
{
Console.Write($"{x} \r");
Thread.Sleep(oRandom.Next(Math.Min(x, 10)));
})
.Run(250, 1, Environment.ProcessorCount * 2 / 3)
.ShowResults(false, true);
BenchmarkLite.Instance.Reset();
BenchmarkLite.Instance
.Title("Benchmark 2")
.Add(() =>
{
Thread.Sleep(oRandom.Next(10));
},
() => { Console.WriteLine("Setup action 0"); },
() => { Console.WriteLine("Cleanup action 0"); },
"Action 0")
.Add(() =>
{
Thread.Sleep(oRandom.Next(10));
})
.Add((x) =>
{
Console.Write($"{x} \r");
Thread.Sleep(oRandom.Next(Math.Min(x, 10)));
},
() => { Console.WriteLine("Setup action 2"); },
() => { Console.WriteLine("Cleanup action 2"); },
"Action 2")
.Add((x) =>
{
Console.Write($"{x} \r");
Thread.Sleep(oRandom.Next(Math.Min(x, 10)));
})
.Run(250, 1, Environment.ProcessorCount * 2 / 3)
.ShowResults(true, true);
Console.WriteLine("Press any key to continue");
Console.ReadKey();
}
}
Output:
--------------------------- Benchmark 1 ---------------------------
Label = Ave Sec Percent Order
[ 0] = 0.295 100.94% 1
[ 1] = 0.304 104.04% 3
[ 2] = 0.302 103.10% 2
[ 3] = 0.293 100.00% 0
Setup action 0
Cleanup action 0
Setup action 0
Cleanup action 0
Setup action 2
Cleanup action 2
Setup action 2
Cleanup action 2
--------------------------- Benchmark 2 ---------------------------
Label = Ave Sec Percent Order
[ Action 0] = 0.298 100.00% 0
[ 1] = 0.299 100.33% 1
[ Action 2] = 0.306 102.41% 2
[ 3] = 0.310 104.06% 3
Press any key to continue