Is there a more popular alternative to benchmarking a .NET application than the library BenchmarkDotNet?
Assistant
BenchmarkDotNet is a popular and well-established benchmarking library for .NET applications, but there are other options available as well. Here are a few alternatives you may want to consider:
NBench: NBench is a benchmarking framework specifically designed for .NET applications. It allows you to write performance tests in C# or F# and supports a variety of performance metrics, including memory consumption and concurrent users.
PerfView: PerfView is a performance analysis tool for .NET applications. While it doesn't offer the same level of flexibility as a benchmarking library, it can help you diagnose performance issues in your application by providing detailed insights into CPU usage, memory allocation, and other performance metrics.
BenchmarkRunner: BenchmarkRunner is a lightweight benchmarking library that focuses on simplicity and ease of use. It supports a range of benchmark types, including microbenchmarks and integration tests, and integrates with other .NET testing frameworks like xUnit and NUnit.
JMeter: JMeter is a popular open-source tool for load testing web applications. While it's not specific to .NET, it can be used to test the performance of any web-based application, including those built with .NET.
These are just a few of the many options available for benchmarking and performance testing .NET applications. Which one you choose will depend on your specific needs and preferences.
User
Which one would you say is better suited for a corporative team?
Assistant
Choosing a benchmarking library for a corporate team will depend on your specific needs and requirements. That said, here are some factors to consider when evaluating different benchmarking libraries:
Ease of use: A benchmarking library that is easy to use and set up can save time and reduce the learning curve for your team.
Flexibility: A benchmarking library that is flexible and can be adapted to your specific requirements is important for a corporate team, where different projects may have different performance requirements.
Integration with existing tools: If your team is already using specific testing or development tools, it's worth considering a benchmarking library that integrates with those tools.
Documentation and support: Robust documentation and good support can help ensure that your team can effectively use the benchmarking library and address any issues that arise.
Based on these factors, BenchmarkDotNet is a popular and well-regarded choice for corporate teams. It is easy to use and provides a wide range of features and options for benchmarking .NET applications. However, it's important to evaluate all options and choose the library that best meets your specific requirements.
User
How would we implement it in a corporate solution?
Assistant
Implementing a benchmarking library in a corporate solution will depend on your specific requirements, but here are some general steps you can follow:
Evaluate different benchmarking libraries: Research and evaluate different benchmarking libraries, taking into account your specific requirements and constraints.
Set up the benchmarking library: Once you have
User
How would we incorporate it for BenchmarkDotNet specifically?
Assistant
To incorporate BenchmarkDotNet into a corporate solution, here are some general steps you can follow:
Add the BenchmarkDotNet package: The first step is to add the BenchmarkDotNet package to your project. You can do this using NuGet or by adding the package reference to your project file.
Write benchmark tests: Once you have added the package, you can start writing benchmark tests. A benchmark test is a method that you decorate with the [Benchmark] attribute, and it should contain the code that you want to test.
Configure the benchmark tests: You can configure the benchmark tests using attributes and fluent configuration methods. For example, you can set the number of iterations, the number of warmup iterations, and the precision of the results.
Run the benchmarks: Once you have written and configured the benchmark tests, you can run them using the BenchmarkRunner. You can run the benchmarks from the command line, Visual Studio, or using a build server.
Analyze the results: BenchmarkDotNet generates detailed benchmark results, including statistical data and performance metrics. You can analyze these results to identify performance issues and optimize your code.
Integrate with your existing tools: BenchmarkDotNet integrates with a range of tools, including Visual Studio, Azure DevOps, and GitHub. You can configure your build pipeline to run the benchmarks and analyze the results automatically.
These are the general steps you can follow to incorporate BenchmarkDotNet into your corporate solution. However, the specific implementation will depend on your project and requirements.
User
What's the best practice to implement that without 'polluting' the code?
Assistant
To implement BenchmarkDotNet without "polluting" your codebase, you can follow these best practices:
Use separate benchmark projects: To keep your benchmarking code separate from your production code, create a separate project for your benchmark tests. This will help keep your codebase organized and make it easier to manage.
Use conditional compilation: You can use preprocessor directives to conditionally compile your benchmark tests. This will ensure that your benchmarking code is only compiled when you need it, and it won't affect the performance or functionality of your production code.
Use the BenchmarkSwitcher class: BenchmarkDotNet provides a BenchmarkSwitcher class that you can use to run your benchmark tests from the command line. This allows you to run your benchmarks independently of your production code and without having to include benchmarking code in your main project.
Use attributes and annotations: BenchmarkDotNet allows you to annotate your benchmark methods and classes with attributes that specify how the benchmark should be run. By using these attributes, you can keep your benchmarking code separate from your production code and avoid "polluting" your main codebase.
Configure logging and output: BenchmarkDotNet provides a range of configuration options for logging and output. You can configure the library to output results to a file, console, or database, and you can also configure the level of detail and formatting of the results.
By following these best practices, you can implement BenchmarkDotNet in a way that keeps your codebase organized and separate from your production code, while still allowing you to effectively benchmark and optimize your code.
User
Give me details and a concrete implementation for each of these please.
Assistant
Certainly! Here are the details and concrete implementations for each of the best practices for implementing BenchmarkDotNet without "polluting" your codebase:
Use separate benchmark projects: To keep your benchmark tests separate from your production code, create a new project in your solution for your benchmarks. Here's an example:
Right-click on your solution and select "Add" > "New Project".
Choose "Console App (.NET Core)" as the project type.
Name your project something like "MyProject.Benchmarks".
Install the BenchmarkDotNet NuGet package in your benchmark project.
Write your benchmark tests in the benchmark project.
Use conditional compilation: You can use preprocessor directives to conditionally compile your benchmark tests. Here's an example:
csharp
#if BENCHMARK
[Benchmark]
public void MyBenchmark()
{
// Benchmark code goes here
}
#endif
In this example, the [Benchmark] attribute will only be applied if the BENCHMARK preprocessor symbol is defined. You can define this symbol in your benchmark project's properties or using a #define directive at the top of your benchmark code.
3. Use the BenchmarkSwitcher class: BenchmarkDotNet provides a BenchmarkSwitcher class that you can use to run your benchmark tests from the command line. Here's an example:
csharp
using BenchmarkDotNet.Running;
public static void Main(string[] args)
{
var summary = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
In this example, the BenchmarkSwitcher class is used to run all the benchmarks in the current assembly. You can pass command-line arguments to the Run method to control which benchmarks are run and how they are run.
4. Use attributes and annotations: BenchmarkDotNet allows you to annotate your benchmark methods and classes with attributes that specify how the benchmark should be run. Here's an example:
csharp
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.NetCoreApp50)]
public class MyBenchmarkClass
{
[Benchmark]
public void MyBenchmarkMethod()
{
// Benchmark code goes here
}
}
User
Give me the boilerplate code for configuring it in a separate project.
Assistant
Sure! Here is a basic example of how to configure BenchmarkDotNet in a separate project:
Create a new project in your solution for your benchmarks. Right-click on your solution in the Solution Explorer, select "Add" > "New Project", choose "Console App (.NET Core)" as the project type, and give your project a name (e.g. "MyProject.Benchmarks").
Install the BenchmarkDotNet NuGet package in your benchmark project. You can do this by right-clicking on your project in the Solution Explorer, selecting "Manage NuGet Packages...", searching for "BenchmarkDotNet", and installing the package.
Write your benchmark tests in your benchmark project. Here is an example of a basic benchmark test:
csharp
using BenchmarkDotNet.Attributes;
namespace MyProject.Benchmarks
{
[MemoryDiagnoser]
public class MyBenchmarkClass
{
[Benchmark]
public void MyBenchmarkMethod()
{
// Code to be benchmarked goes here
}
}
}
In this example, the [MemoryDiagnoser] attribute is used to enable memory profiling, and the [Benchmark] attribute is used to mark the method that should be benchmarked.
In your benchmark project, create a new class that will contain the Main method that will be used to run the benchmarks. Here is an example of how to do this:
csharp
using BenchmarkDotNet.Running;
namespace MyProject.Benchmarks
{
class Program
{
static void Main(string[] args)
{
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
}
In this example, the BenchmarkSwitcher class is used to run all the benchmarks in the current assembly (i.e. the benchmark project). You can customize the arguments passed to the Run method to control which benchmarks are run and how they are run.
That's it! With these steps, you should be able to configure and run BenchmarkDotNet in a separate project without polluting your production code.
User
What's the best practices? Should we have one benchmark class per service like we do with unit tests ?
Assistant
The best practice for organizing benchmark tests depends on the specific needs and structure of your application. However, here are some general guidelines that can help:
Group benchmarks based on the code that is being benchmarked. This can mean creating benchmark classes for specific services, classes, methods, or other components of your codebase.
Consider creating a separate benchmark project for your benchmarks, as this can make it easier to manage dependencies and ensure that the benchmark code does not affect the production code.
Aim to keep your benchmarks focused and simple. Each benchmark should ideally test a specific aspect of the code's performance, rather than trying to cover too many use cases in a single test. This can help make your benchmarks more reliable and easier to interpret.
Use descriptive names for your benchmark classes and methods to make it easy to understand what is being benchmarked.
Consider using tags or attributes to label your benchmarks, which can help you filter and group them based on their characteristics (e.g. testing a specific implementation, or focusing on memory usage).
In terms of having one benchmark class per service, this can be a reasonable approach if you have a large and complex application with many services or components that need to be benchmarked. However, it may not be necessary or practical for smaller applications or simpler codebases. It's generally a good idea to group your benchmarks based on the needs of your specific application, rather than following a strict rule about how many classes to use.
User
Give me a full list of benchmark attributes with their description.
Assistant
Certainly! Here is a list of the most commonly used BenchmarkDotNet attributes, along with a brief description of what they do:
[Benchmark]: This attribute marks a method as a benchmark method that should be executed during benchmarking.
[Params]: This attribute specifies a set of parameters to use when running the benchmark method. This can be used to test the method with different inputs or settings.
[ParamsSource]: This attribute specifies a class that will provide the parameter sets for the benchmark. This can be useful if you have a large number of parameters or if the parameters are generated dynamically.
[Setup]: This attribute marks a method that should be executed before each benchmark iteration. This can be used to initialize objects or set up test data.
[IterationSetup]: This attribute marks a method that should be executed before each iteration of the benchmark. This can be used to perform setup tasks that are not affected by the benchmark method.
[Cleanup]: This attribute marks a method that should be executed after each benchmark iteration. This can be used to clean up objects or reset test data.
[IterationCleanup]: This attribute marks a method that should be executed after each iteration of the benchmark. This can be used to perform cleanup tasks that are not affected by the benchmark method.
[GlobalSetup]: This attribute marks a method that should be executed once before all benchmark iterations. This can be used to perform setup tasks that are expensive or time-consuming.
[GlobalCleanup]: This attribute marks a method that should be executed once after all benchmark iterations. This can be used to perform cleanup tasks that are expensive or time-consuming.
[ParamsAllValues]: This attribute specifies that all possible combinations of the provided parameters should be used in the benchmark. This can be useful if you want to test all possible configurations of a complex system.
[MemoryDiagnoser]: This attribute enables memory profiling during benchmarking. This can be useful for identifying memory leaks or other performance issues related to memory usage.
[StopwatchDiagnoser]: This attribute enables detailed timing information during benchmarking, including the overhead of the benchmarking framework itself. This can be useful for understanding the true performance characteristics of the benchmarked code.
[HardwareCounters]: This attribute enables hardware performance counters during benchmarking, allowing you to measure low-level performance metrics like cache hits and misses, branch mispredictions, and CPU cycles.
User
Not always clear. Give the description for each one with explanations on why it would be used.
Assistant
Sure, here are more detailed descriptions for each of the commonly used attributes in BenchmarkDotNet, along with explanations of when and why they might be used:
[Benchmark]: This attribute marks a method as a benchmark method that should be executed during benchmarking. This is the most basic and important attribute in BenchmarkDotNet, and is required for every benchmark.
[Params]: This attribute specifies a set of parameters to use when running the benchmark method. This can be used to test the method with different inputs or settings. For example, you might use this attribute to test how the performance of a sorting algorithm varies with the size of the input array.
[ParamsSource]: This attribute specifies a class that will provide the parameter sets for the benchmark. This can be useful if you have a large number of parameters or if the parameters are generated dynamically. For example, you might use this attribute to test how the performance of a network service varies with different message sizes.
[Setup]: This attribute marks a method that should be executed before each benchmark iteration. This can be used to initialize objects or set up test data. For example, you might use this attribute to create an instance of a complex object that will be used in the benchmark.
[IterationSetup]: This attribute marks a method that should be executed before each iteration of the benchmark. This can be used to perform setup tasks that are not affected by the benchmark method. For example, you might use this attribute to initialize a connection to a database or network service.
[Cleanup]: This attribute marks a method that should be executed after each benchmark iteration. This can be used to clean up objects or reset test data. For example, you might use this attribute to close a file or network connection that was used in the benchmark.
[IterationCleanup]: This attribute marks a method that should be executed after each iteration of the benchmark. This can be used to perform cleanup tasks that are not affected by the benchmark method. For example, you might use this attribute to clean up temporary files or log data.
[GlobalSetup]: This attribute marks a method that should be executed once before all benchmark iterations. This can be used to perform setup tasks that are expensive or time-consuming. For example, you might use this attribute to create a large database that will be used in the benchmark.
[GlobalCleanup]: This attribute marks a method that should be executed once after all benchmark iterations. This can be used to perform cleanup tasks that are expensive or time-consuming. For example, you might use this attribute to delete a large database that was created during the benchmark.
User
Please continue
Assistant
useful for understanding the performance of code at a low level and identifying specific bottlenecks or areas for optimization. For example, you might use this attribute to identify which parts of a complex algorithm are causing the most cache misses or branch mispredictions.
[RankColumn]: This attribute specifies that a benchmark column should be ranked by its values, rather than alphabetically. This can be useful for comparing benchmarks based on their performance metrics. For example, you might use this attribute to rank benchmarks by their execution time, so that the fastest benchmarks appear at the top of the results.
[MeanColumn]: This attribute specifies that a benchmark column should display the mean value of the benchmark, rather than the default median value. This can be useful for getting a sense of the average performance of the benchmark. For example, you might use this attribute to see the average execution time of a benchmark over multiple iterations.
[StdDevColumn]: This attribute specifies that a benchmark column should display the standard deviation of the benchmark. This can be useful for understanding the variability of the benchmark results. For example, you might use this attribute to see how consistent the performance of a benchmark is across multiple iterations.
[SummaryExporter]: This attribute specifies an exporter that should be used to export the benchmark results to a file or external service. This can be useful for integrating BenchmarkDotNet into a larger testing or reporting system. For example, you might use this attribute to export benchmark results to a database or cloud service.
[IterationTime]: This attribute specifies the maximum time that each benchmark iteration should run. If the iteration takes longer than this time, it will be stopped and the results will be recorded. This can be useful for limiting the amount of time that a benchmark runs, or for catching benchmarks that take an unusually long time to execute.
[InvocationCount]: This attribute specifies the number of times that the benchmark method should be executed in each iteration. This can be useful for ensuring that the benchmark is representative of the actual performance of the code. For example, you might use this attribute to execute a benchmark method multiple times to account for any variability in the results.
These are some of the most commonly used attributes in BenchmarkDotNet, but there are many others available as well. You can find a complete list of available attributes in the official BenchmarkDotNet documentation.
User
If I have a microservices with an API gateway pattern architecture. Should benchmarking be done at the gateway level or individually for each microservice?
Assistant
The answer to this question depends on what you want to achieve with your benchmarks. If your goal is to optimize the overall performance of your microservices system, then you should consider benchmarking at both the gateway level and individually for each microservice.
Benchmarking at the gateway level can help you identify bottlenecks in the API gateway itself, such as authentication, routing, or other services that the gateway provides. It can also help you understand how the different microservices are being used together and identify any performance issues caused by the interactions between them.
Benchmarking at the microservice level can help you identify specific areas where you can optimize the performance of each microservice. This can be especially useful if you have a large or complex microservices system with many different services and endpoints.
In general, it's a good practice to benchmark both at the gateway level and individually for each microservice to get a complete picture of the performance of your system. You may also want to consider running benchmarks in different scenarios or with different load levels to ensure that your system performs well under different conditions.
User
With SonarQube in our pipeline, is there a benchmarking feature similar to BenchmarkDotNet?
Assistant
SonarQube is primarily a code quality and security analysis tool, and it does not include a benchmarking feature similar to BenchmarkDotNet. However, SonarQube can be integrated with other tools that provide benchmarking capabilities to help you track performance issues and identify areas for optimization.
One example of a tool that can be integrated with SonarQube for benchmarking is JMeter. JMeter is an open-source tool for load testing and performance measurement of web applications. It can be used to simulate a high volume of requests to your application and measure its response time and other performance metrics.
To integrate JMeter with SonarQube, you can use the JMeter plugin for SonarQube. This plugin allows you to import JMeter test results into SonarQube and display them alongside other code quality and security metrics. You can then use SonarQube's reporting and visualization tools to analyze the performance of your application and identify any bottlenecks or areas for optimization.
Another option for benchmarking in a SonarQube pipeline is to use a dedicated benchmarking tool like BenchmarkDotNet outside of SonarQube, and then import the results into SonarQube using a plugin or other integration. This can give you a more detailed and accurate view of your application's performance, and help you identify specific areas for optimization.
In summary, while SonarQube does not provide a benchmarking feature similar to BenchmarkDotNet, it can be integrated with other tools like JMeter to help you track the performance of your application and identify areas for optimization.
User
So, the good practice would be to use JMeter with SonarQube in the pipeline and BenchmarkDotNet in the code?
Assistant
Yes, that could be a good practice. JMeter can be used to simulate a high volume of requests to your application and measure its response time and other performance metrics. You can then import the JMeter test results into SonarQube using the JMeter plugin for SonarQube, which allows you to display the performance metrics alongside other code quality and security metrics. This can help you analyze the performance of your application and identify any bottlenecks or areas for optimization.
BenchmarkDotNet, on the other hand, is a library for benchmarking .NET code, and can be used to measure the performance of individual code components or methods. You can use this library to measure the performance of different implementations of your code and identify the most efficient one. While BenchmarkDotNet is not integrated with SonarQube directly, you can still use it in your code and import the results into SonarQube using a plugin or other integration.
Using both JMeter with SonarQube and BenchmarkDotNet can give you a complete view of the performance of your application, both at the system level and the code level. This can help you identify specific areas for optimization and ensure that your application is performing well under different conditions.
User
You say 'Another option for benchmarking in a SonarQube pipeline is to use a dedicated benchmarking tool like BenchmarkDotNet outside of SonarQube, and then import the results into SonarQube using a plugin or other integration.' Is it the same as JMeter or JMeter would better fit that use case?
Assistant
JMeter and BenchmarkDotNet serve different purposes and are suited for different types of benchmarking.
JMeter is primarily used for load testing and performance measurement of web applications. It simulates a high volume of requests to your application and measures its response time and other performance metrics. JMeter can be integrated with SonarQube using the JMeter plugin for SonarQube, which allows you to import JMeter test results into SonarQube and display them alongside other code quality and security metrics.
On the other hand, BenchmarkDotNet is a library for benchmarking .NET code. It allows you to measure the performance of individual code components or methods. You can use this library to measure the performance of different implementations of your code and identify the most efficient one. While BenchmarkDotNet is not integrated with SonarQube directly, you can still use it in your code and import the results into SonarQube using a plugin or other integration.
So, if you want to measure the performance of your web application under load, JMeter would be a better fit. On the other hand, if you want to measure the performance of specific code components or methods, BenchmarkDotNet would be a better fit. However, both JMeter and BenchmarkDotNet can be integrated with SonarQube using plugins or other integrations, so you can import the results into SonarQube and view them alongside other code quality and security metrics.
User
What would SonarQube do with the results imported from BenchmarkDotNet?
Assistant
When you import benchmark results from BenchmarkDotNet into SonarQube, you can use the SonarQube .NET plugin to display the results in the SonarQube dashboard.
The .NET plugin provides a "Performance" widget that displays the results of your benchmark tests alongside other performance-related metrics, such as the number of warnings, errors, and code smells in your code. The Performance widget displays the following metrics for each benchmark test:
Mean: the average time taken by the benchmark method to execute, in seconds.
Standard deviation: a measure of how much the individual measurement results differ from the mean, in seconds.
Error: a measure of the statistical error associated with the measurement, in seconds.
N: the number of iterations used in the benchmark test.
These metrics can help you identify performance issues in your code and track your progress in optimizing your application's performance. You can also use the SonarQube dashboards and reports to drill down into specific code components or methods and identify areas for optimization.
In addition to displaying the benchmark results, the SonarQube .NET plugin also allows you to set performance thresholds for your benchmark tests. This can help you ensure that your code meets specific performance requirements, and that any changes to the code do not significantly degrade its performance.
User
However, that would be limited to projects in .NET, JMeter would be a better option if we decide to have projects in another language like Python or Rust right?
Assistant
Yes, that's correct. While the SonarQube .NET plugin is designed to work with .NET projects, JMeter is a more versatile tool that can be used to test the performance of applications written in a variety of languages, including Python and Rust.
JMeter supports a range of protocols and technologies, including HTTP, HTTPS, SOAP, REST, JMS, FTP, SMTP, and others. It can be used to test the performance of web applications, databases, and other backend systems, regardless of the language or platform they are built on.
In addition, JMeter is an open-source tool with a large and active community of users, which means that you can find plenty of resources, tutorials, and plugins to help you get started with JMeter and extend its functionality to suit your specific testing needs.
So, if you are working with projects in languages other than .NET, JMeter would be a better option for load testing and performance measurement, especially if you want to test a variety of protocols and technologies.
User
Could both be used at the same time? BenchmarkDotNet for .NET microservices and JMeter for other microservices or would this become too hard to manage in the pipeline with SonarQube?
Assistant
Yes, it is possible to use both BenchmarkDotNet and JMeter in the same pipeline with SonarQube, although it could add some complexity to the pipeline management.
If you have a mix of microservices built on .NET and other languages, you could use BenchmarkDotNet to benchmark the .NET microservices and JMeter to test the performance of the other microservices. You could then import the results from both tools into SonarQube to get a comprehensive view of the performance of your entire system.
However, this approach could require some additional setup and configuration to ensure that the pipeline runs smoothly and that the results from both tools are correctly integrated into SonarQube. You may need to create separate stages or jobs in your pipeline to handle the different types of tests, and you may need to use different plugins or integrations to import the results into SonarQube.
In general, it's a good idea to keep your pipeline as simple as possible, so if you can stick with one tool for all your performance testing needs, that would be ideal. However, if you have a mix of technologies and need to use multiple tools, it is possible to integrate them into your pipeline with SonarQube, as long as you are willing to put in the extra effort to set things up correctly.
Dataset releases
Not yet included in a published release.
In this example, the [MemoryDiagnoser] and [SimpleJob] attributes are used to configure the benchmark. The [Benchmark] attribute is used to mark the benchmark method. You can use a range of other attributes to configure the benchmark as needed.
5. Configure logging and output: BenchmarkDotNet provides a range of configuration options for logging and output. Here's an example:
csharp
public static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<MyBenchmarkClass>(
new ConsoleLogger(),
new CsvExporter(CsvSeparator.Comma, new SummaryStyle())
);
}
In this example, the BenchmarkRunner class is used to run the MyBenchmarkClass benchmark, with logging to the console and output to a CSV file. You can configure the logger and exporter as needed to suit your requirements.
By following these best practices, you can effectively implement BenchmarkDotNet in your codebase without polluting your production code.
[RankColumn]: This attribute specifies that a column should be added to the benchmark results that ranks the performance of each benchmark based on some criteria (e.g. execution time, memory usage, etc.).
[GroupBenchmarksBy]: This attribute specifies how the benchmarks should be grouped in the benchmark results. This can be useful for comparing different implementations or configurations of the same code.
These are just a few of the most commonly used attributes in BenchmarkDotNet. There are many others available, so be sure to consult the documentation for a complete list and detailed descriptions of each attribute.
[ParamsAllValues]: This attribute specifies that all possible combinations of the provided parameters should be used in the benchmark. This can be useful if you want to test all possible configurations of a complex system. For example, you might use this attribute to test the performance of a sorting algorithm with different data types and array sizes.
[MemoryDiagnoser]: This attribute enables memory profiling during benchmarking. This can be useful for identifying memory leaks or other performance issues related to memory usage. For example, you might use this attribute to track how much memory is allocated during each iteration of a benchmark.
[StopwatchDiagnoser]: This attribute enables detailed timing information during benchmarking, including the overhead of the benchmarking framework itself. This can be useful for understanding the true performance characteristics of the benchmarked code. For example, you might use this attribute to see how much time is spent in the framework versus the benchmarked code.
[HardwareCounters]: This attribute enables hardware performance counters during benchmarking, allowing you to measure low-level performance metrics like cache hits and misses, branch mispredictions, and CPU cycles. This can be