I created a small benchmark that compared the performance of my application logic with logging enabled vs disabled.
Here is a (simplified) version of my code:
Executed is triggered in the Program.cs
file:
However when I executed the benchmark using Benchmarkdotnet, I got the following warnings:
// * Warnings *
MinIterationTime
NHibernateWithAndWithoutLoggingEnabled.WithLogging: InvocationCount=1, UnrollFactor=1 -> The minimum observed iteration time is 20.9305 ms which is very small. It's recommended to increase it to at least 100.0000 ms using more operations.
NHibernateWithAndWithoutLoggingEnabled.WithoutLogging: InvocationCount=1, UnrollFactor=1 -> The minimum observed iteration time is 19.2794 ms which is very small. It's recommended to increase it to at least 100.0000 ms using more operations.
You get these warnings when the operation you want to benchmark is very short. As this can lead to unstable results, a warning is produced. To get rid of the warning you should include more operations to increase the execution time.
FIX: For this application I introduced a loop in the benchmark code to execute the same method enough times to reach the minimal suggested timing(100.000 ms).