BenchmarkLiteLib 1.0.1
dotnet add package BenchmarkLiteLib --version 1.0.1
NuGet\Install-Package BenchmarkLiteLib -Version 1.0.1
<PackageReference Include="BenchmarkLiteLib" Version="1.0.1" />
paket add BenchmarkLiteLib --version 1.0.1
#r "nuget: BenchmarkLiteLib, 1.0.1"
// Install BenchmarkLiteLib as a Cake Addin #addin nuget:?package=BenchmarkLiteLib&version=1.0.1 // Install BenchmarkLiteLib as a Cake Tool #tool nuget:?package=BenchmarkLiteLib&version=1.0.1
A lightweight and simple benchmark tool. This is a compiled version of BenchmarkLite.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
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.
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