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 |
timcassell
left a comment
There was a problem hiding this comment.
Thanks @AvishaiDotan!
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.