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

Add support for HHVM compatible xhprof_frame_begin & xhprof_frame_end #51

Open
bd808 opened this issue Nov 18, 2014 · 1 comment · May be fixed by #52
Open

Add support for HHVM compatible xhprof_frame_begin & xhprof_frame_end #51

bd808 opened this issue Nov 18, 2014 · 1 comment · May be fixed by #52

Comments

@bd808
Copy link

bd808 commented Nov 18, 2014

The HHVM implementation of XHProf includes two handy functions and a wrapper class to allow sub-function profiling:

  • xhprof_frame_begin : Starts an artificial frame. Together with xhprof_frame_end(), this times one block of code execution as if it were a function call, allowing people to define arbitrary function boundaries. Prefer to use XhprofFrame classobjects instead of calling this function directly.
  • xhprof_frame_end : Ends an artificial frame that xhprof_frame_begin() started. One has to make sure there are no exceptions in between these two calls, as otherwise, it may report incorrect timings. Also, xhprof_frame_begin() and xhprof_frame_end() have to be paired up really well, so not to interfere with regular function's profiling, unless that's the intention. Prefer to use XhprofFrame classobjects instead of calling this function directly.
  • XhprofFrame : Wrapper object that calls xhprof_frame_begin in its constructor and xhprof_frame_end in its destructor.
class XhprofFrame {
  public function __construct($name) {
    xhprof_frame_begin($name);
  }
  public function __destruct() {
    xhprof_frame_end();
  }
}
@bd808
Copy link
Author

bd808 commented Nov 18, 2014

It looks to me like the implementation of these functions would be relatively straight forward wrappers around the BEGIN_PROFILING/END_PROFILING macros.

Having this support in the XHProf pecl extension would be very nice for libraries that are concerned about sub-function profiling and attempting to be compatible with both the PHP5 and HHVM interpreters.

@bd808 bd808 linked a pull request Nov 28, 2014 that will close this issue
remicollet pushed a commit to remicollet/xhprof that referenced this issue Jul 5, 2021
Use PHP 8.0 Observer API
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 a pull request may close this issue.

1 participant