Skip to content
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

file_reporter argument to RunSpecifiedBenchmarks should be optional, but is not #836

Open
tlang0 opened this issue Jul 12, 2019 · 2 comments

Comments

@tlang0
Copy link

tlang0 commented Jul 12, 2019

In the comment/documentation of RunSpecifiedBenchmarks in benchmark.h, it says:

// The second and third overload use the specified 'display_reporter' and
// 'file_reporter' respectively. 'file_reporter' will write to the file
// specified
// by '--benchmark_output'. If '--benchmark_output' is not given the
// 'file_reporter' is ignored.

The first problem is that the correct argument name is benchmark_out (I assume it was changed at some point).
The second problem is that the last sentence is not true. If ' --benchmark_out' is not given, the following message is displayed:

A custom file reporter was provided but --benchmark_out= was not specified.

I don't know which is the intended behavior, but to me, it would make sense that the file_reporter is ignored if '--benchmark_out' is not specified.

@dmah42
Copy link
Member

dmah42 commented Jul 12, 2019 via email

@tlang0
Copy link
Author

tlang0 commented Jul 24, 2019

Thank you for your answer and sorry for my late response.

My intention was to provide a custom JSONReporter which is used only if the benchmark is executed with the --benchmark_out parameter pointing to a JSON output file. Otherwise, there would just be the console output. This way, the user can decide if they want to have the additional JSON output written to a file or just the console output.

This is exactly how it works if no custom BenchmarkReporter is provided. If the --benchmark_out argument is set, the results are written to the specified file using the format specified by --benchmark_out_format. Otherwise, only the console output is produced.

If a custom BenchmarkReporter is provided as file_reporter argument to RunSpecifiedBenchmarks, the behavior changes. Now, it is no longer possible to execute the benchmark without the --benchmark_out parameter. It only allows writing to a file. This means that with the custom file_reporter, the user can no longer decide if they want to see the output directly or if it should be written to a file.

This difference in behavior is why I thought that it is probably an error (not just in the documentation, but in the behavior). But I might just have overlooked something or misunderstood the function parameters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants