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

Introduce the possibility to customize the help printer function #1342

Merged
merged 4 commits into from
Feb 16, 2022

Conversation

vincenzopalazzo
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo commented Feb 8, 2022

This is the first attempt to introduce an help_printer function.

But there are a few things that I don't like, such as:

  • Depending on the stdio in the benchamark.h
  • The global definition of the function hprintf in benchmark.cc

But I think it is a good starting point to start to discuss about it

Fixes #1329

@dmah42
Copy link
Member

dmah42 commented Feb 8, 2022

could you resolve the CLA issue please?

@vincenzopalazzo
Copy link
Contributor Author

@dominichamon I was sure to have tested it in my branch, sorry I will fix right now.

@dmah42
Copy link
Member

dmah42 commented Feb 8, 2022

@dominichamon I was sure to have tested it in my branch, sorry I will fix right now.

no problem at all.. as well as the test failures it looks like you'll need to click the CLA and sign it before we can take your patch.

@vincenzopalazzo vincenzopalazzo force-pushed the vincenzopalazzo/help_function branch 2 times, most recently from 9b2b326 to 5c8988a Compare February 8, 2022 18:14
@vincenzopalazzo
Copy link
Contributor Author

no problem at all.. as well as the test failures it looks like you'll need to click the CLA and sign it before we can take your patch.

Right, I did it, thanks

@vincenzopalazzo vincenzopalazzo force-pushed the vincenzopalazzo/help_function branch 2 times, most recently from f036c54 to d63fea0 Compare February 12, 2022 20:52
@@ -1203,6 +1204,24 @@ class LambdaBenchmark : public Benchmark {
};
#endif

inline void helper_printer() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be inline? (nit, it should be HelperPrinter)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to catch my naming convention error, sorry my last C experience changes my naming convention in my mind :/ Sorry.

In addition, I use the inline function only because I have some redefinition function at compiler time.

The solution, in this case, can be:

  • define the prototype of the function in the .h file and add the definition in the .cc file;
  • use the nullprt in the function and define an HelperPrinter in the .cc file, so we can hide all the logic.

In both cases, we have some not clear states of the HelperPrintf function that is used to store the procedure to print the help information.

Maybe it is my missing some knowledge of c++ in this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defining the prototype (declaring) in the header and having the implementation (definition) in the .cc file seems reasonable to me. there's no reason i can see to have the implementation in the header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defining the prototype (declaring) in the header and having the implementation (definition) in the .cc file seems reasonable to me. there's no reason i can see to have the implementation in the header.

With the following solution, I had some problems with the dynamic linker (https://github.com/vincenzopalazzo/benchmark/runs/5204928772?check_suite_focus=true) and I implemented your first suggestion to use the NULL pointer.

Open to other suggestions to improve the actual solution.

Copy link
Member

@dmah42 dmah42 Feb 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like you maybe had the definition in the wrong place... maybe it wasn't in the benchmark namespace but in the benchmark::internal namespace.

either way, i think your current version is clean. waiting for the bots to agree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ops, maybe I made this stupid error, but was a good moment to try the following solution, that introduces less code, that it is always good IMHO

@vincenzopalazzo vincenzopalazzo force-pushed the vincenzopalazzo/help_function branch 2 times, most recently from 50e78b2 to f001ed4 Compare February 14, 2022 20:21
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
…t method

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@dmah42 dmah42 merged commit c563644 into google:main Feb 16, 2022
@dmah42
Copy link
Member

dmah42 commented Feb 16, 2022

thanks

@vincenzopalazzo
Copy link
Contributor Author

Thank you for your time.

I will be around, so if there are other issues where you would like to see into it, just assign them to me.

@vincenzopalazzo vincenzopalazzo deleted the vincenzopalazzo/help_function branch February 16, 2022 09:26
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

Successfully merging this pull request may close these issues.

[FR] Command line help hook
2 participants