Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds maliput profiler #538
Adds maliput profiler #538
Changes from 5 commits
448f86b
5097cab
9b9fed9
bd04adf
65bb428
37c9d05
9b96910
2bf6ce2
22ff1d8
209cc9d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use @def MALIPUT_PROFILER_ENABLE ....
Which value should we use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This states that if the
MALIPUT_PROFILER_ENABLE
is not defined then set it to zero. (as it is done in the very line below)And the define is expected to bet set via preprocessor : cmake-ars --> compile definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use
__FUNC__
/__PRETTY_FUNCTION__
(even better but not sure if it is available in clang ) ?That will allow to reduce the cost to implement the profiling everywhere, meaning that we don't need to review spelling mistakes and so on and the compiler will do it for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could create a new macro like
Finally, we are using the profiler for analyzing entire method execution, however, it could be used por different part of a method. For example, check this usecase in gz-sim::simulationrunner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the macro
#define MALIPUT_PROFILE_FUNC() IGN_PROFILE(__FUNCTION__)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about also adding the option with pretty_function? Check 22ff1d8
In the api I am still using the
MALIPUT_PROFILE
macro as it is better described.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is OK, but I would use it everywhere we are using the name of the function only to avoid spelling mistakes. Also, the macro could be (I hope the compiler shakes my right hand):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, are these
__FUNCTION__
and__PRETTY_FUNCTION
in any of the standards? Never saw them before. If they are not, not sure guys how you deal with this platform constraints decisions in maliput.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question,
__FUNCTION__
is part of the C++ standard already. Regarding__PRETTY_FUNCTION__
apparently it is not in the standard (at least yet) however gcc and clang have support for this. Given that we state to support both gcc and clang compilers, I think that there is no harm in using them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with
#define MALIPUT_PROFILE_FUNC_MSG(msg) IGN_PROFILE(__FUNCTION_": "#msg)
is the argument:IGN_PROFILER is expecting a
char *
and :__FUNCTION__": "#msg
__FUNCTION__ + ": " + #msg
aren't correct.
There is an alternative of concatenating as a string and converting to const char * but making this conversion/operation every time that the method is called isn't ideal.
#define MALIPUT_PROFILE_FUNC_MSG(msg) IGN_PROFILE((static_cast<std::string>(__FUNCTION__) + std::string(": ") + static_cast<std::string>(msg)).c_str())
I replaced all the occurrences with
MALIPUT_PROFILE_FUNC()
Check 209cc9dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Let's keep it as is then.