BenchmarkLiteLib 1.0.1

BenchmarkLite lib

A lightweight and simple benchmark tool.  This is a compiled version of BenchmarkLite.

Install-Package BenchmarkLiteLib -Version 1.0.1
dotnet add package BenchmarkLiteLib --version 1.0.1
<PackageReference Include="BenchmarkLiteLib" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BenchmarkLiteLib --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Release Notes

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

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
1.0.1 330 12/2/2016
1.0.0 262 12/2/2016