add hierarachical time breakdown feature #27
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.
Description
This PR refactors the Timer utility to introduce a hierarchical timer tree structure, also add a feature that timer can support manually stop.
Key Changes:
src/oops/util/Timer.cc
: The Timer class now tracks its position within a call tree using TimerHelper and a new stopped_ flag to prevent duplicate time logging.src/oops/util/TimerHelper.cc
&src/oops/util/TimerHelper.h
: The TimerHelper is updated to manage a new TimerTree class, including methods to navigate the tree (goDown, goUp) and to print the complete hierarchical timing structure.src/oops/util/TimerTree.h
: This new file defines the TimerTree class, which handles the creation and management of the hierarchical timer structure and includes a method to print the tree in a unix tree command like format.Useage
We can use it as before, declare timer in the beginning of the code section and it will auto destruct when exit block. Another usage (new) is wrapping the statements we want to measure time using timer declaration and explicit timer.stop.
For example: