-
-
Notifications
You must be signed in to change notification settings - Fork 991
Log a warning when an empty benchmark is run #2718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Log a warning when an empty benchmark is run #2718
Conversation
…redundant check for any benchmark
Hi @timcassell, Apologies for the continuous test runs. I prefer working directly on the branch, and every time I push changes—even when the PR is marked as a draft—it still triggers the tests. As a side note, it might be a good idea to update the CI/CD configuration so tests only run when the PR is not in draft mode. |
Error is printed when I use BenchmarkRunner.Run<Benchmark>(); But nothing is printed when I use BenchmarkRunner.Run(typeof(Program).Assembly); |
I've tested running the assembly without any benchmarks using the following methods, and the implementation did not fail in either case:
In both scenarios, the implementation worked as expected. Could you please elaborate on how you ran |
Just like this. No benchmark types. public class Program
{
public static void Main(string[] args)
{
BenchmarkRunner.Run(typeof(Program).Assembly);
}
} Ran in Visual Studio, got no output at all. Maybe the validation errors are returned properly, but this particular API isn't logging them? |
You're right. assembly.GetRunnableBenchmarks()
.Select(type => BenchmarkConverter.TypeToBenchmarks(type, config))
.ToArray(); If The key point is: when However, in the case of an empty assembly (i.e., no runnable benchmarks), Possible Solution if (benchmarkRunInfos.Length == 0)
{
AddLogger(new ConsoleLogger());
} This ensures a console logger is present even if no benchmarks are found, so validation errors still get reported. |
I haven't looked into the implementation details, but I did see that |
Fix #2712
I've added a warning using the composite logger to notify when an empty benchmark is executed.
Also included a test to ensure the warning is logged correctly.