BenchmarkLite 1.0.2

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package BenchmarkLite --version 1.0.2
                    
NuGet\Install-Package BenchmarkLite -Version 1.0.2
                    
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="BenchmarkLite" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BenchmarkLite" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="BenchmarkLite" />
                    
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 BenchmarkLite --version 1.0.2
                    
#r "nuget: BenchmarkLite, 1.0.2"
                    
#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 BenchmarkLite@1.0.2
                    
#: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=BenchmarkLite&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=BenchmarkLite&version=1.0.2
                    
Install as a Cake Tool

A lightweight and simple benchmark tool.

There are no supported framework assets in this package.

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