-
Notifications
You must be signed in to change notification settings - Fork 109
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
[feat] Add a lightweight time profiler in the framework #2545
Conversation
348de88
to
a87bd19
Compare
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.
Just two crazy questions...
- Let's imagine that a user would like to also measure their own test hooks...
The timings would be per test, not per test case, right? If that's the case, how could someone add a test case-specific timing? - The intention is to measure the framework, right? That's the reason why the
_profiler
is defined in thecore/logging.py
file... However, would it make sense to have a timing function on the utilities? Especially to help with question 1?
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.
BTW... lgtm
The timings depend on the user. If you use the
Yes, the intention is to measure the framework performance and not to make available –at least for now– the profiler to the users. Let's concrete cases where this could be useful and we can "open it up." |
@jenkins-cscs retry daint |
This PR adds a lightweight time profiler for the framework. This is intended to be a standalone package, that's why the
ProfilerError
does not extend theReframeError
. The profiler is hierarchical and maintains a stack of regions. The current region is the one at the top of the stack. Every call toenter_region()
pushes a new named region in the stack and everyexit_region()
pops the last region. For convenience a context manager (time_region
) is provided for timing a code region.The framework uses a global profiler defined in
core/logging.py
and is accessible through thegetprofiler()
call. For convenience we also define two function decorators for profiling any function in the framework using the global profiler. The profiling info is printed in debug output at the end of the framework's execution.An example output of the profiler is the following:
Finally, I measured the overhead of the profiler and is ~1us per
enter/exit_region
combination on my Mac (2.3GHz quad-core Intel Core i5).This PR builds on top of #2544.
Properly fixes #97.