ricardotondello / Functional.Benchmark

Provides functionality to perform and measure benchmarks in C#. The class contains methods to benchmark both synchronous and asynchronous operations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Functional.Benchmark πŸš€

Build Quality Gate Coverage NuGet latest version NuGet downloads

A simple C# class for benchmarking asynchronous and synchronous functions with a focus on functional programming.

Overview πŸ“Š

The FunctionalBenchmark class provides methods for benchmarking asynchronous and synchronous functions using the ValueStopwatch utility.

Usage πŸ’‘

Simply instantiate the FunctionalBenchmark class and use the provided methods for benchmarking your functions and actions.

var benchmark = new FunctionalBenchmark();

benchmark.BenchmarkAsync(async () => await YourAsyncFunction(), stopwatch => YourSyncStopwatchAction(stopwatch));
benchmark.Benchmark(() => YourSyncFunction(), stopwatch => YourSyncStopwatchAction(stopwatch));
// ... and more

// You also can inject in your dependencies
services.AddSingleton<IFunctionalBenchmark, FunctionalBenchmark>()

public static readonly IFunctionalBenchmark _functionalBenchmark;
// Use in your class
public MyClass(IFunctionalBenchmark functionalBenchmark)
{
    _functionalBenchmark = functionalBenchmark;
}

public async Task DoSomenthingAsync()
{
    await _functionalBenchmark.BenchmarkAsync(async () => await YourAsyncFunction(), 
        stopwatch => _logger.LogInformation($"TimeElapsed: {ElapsedTime}", stopwatch.GetElapsedTime().Milleseconds));
}

Contributing πŸ‘₯

Contributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub. If you would like to contribute code, please fork the repository and submit a pull request.

License πŸ“„

This project is licensed under the MIT License. See LICENSE for more information.

Support β˜•

Buy Me A Coffee

About

Provides functionality to perform and measure benchmarks in C#. The class contains methods to benchmark both synchronous and asynchronous operations.

License:MIT License


Languages

Language:C# 100.0%