Profiling with Xhprof
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Profiling with Xhprof

on

  • 1,673 views

Video online: http://www.youtube.com/watch?v=PY1RgLRfatw&feature=youtu.be

Video online: http://www.youtube.com/watch?v=PY1RgLRfatw&feature=youtu.be

Statistics

Views

Total Views
1,673
Views on SlideShare
1,673
Embed Views
0

Actions

Likes
2
Downloads
3
Comments
1

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Profiling with Xhprof Presentation Transcript

  • 1. Profiling with XHProf
  • 2. Installing ● sudo pear upgrade pear ● sudo pecl install -f xhprof ● extension=xhprof.so (in php.ini) ● sudo /etc/init.d/apache2 restart ● Also install graphviz...
  • 3. Completing install with XHprof UI ● Clone the repo! ● Create database. ● Create table (look in the code). ● Adjust the config.php ● Tell your PHP scripts to profile.
  • 4. Collecting profile data ● Enable: ○ xhprof_enable($flags); ● Collect: ○ $data = xhprof_disable();
  • 5. ● Globally: ○ .htaccess &/or php.ini ○ auto_prepend_file = “header.php”; ○ auto_append_file = “footer.php”; Collecting profile data
  • 6. <?php // header.php xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY); <?php // footer.php require_once '/home/tim/Clones/xhprof/xhprof_lib/config.php'; include_once '/home/tim/Clones/xhprof/xhprof_lib/utils/xhprof_lib.php'; include_once '/home/tim/Clones/xhprof/xhprof_lib/utils/xhprof_runs.php'; public function record() { global $_xhprof; // This wasn’t my idea $profile = xhprof_disable(); $xhprof = new XHProfRuns_Default(); $xhprof->save_run($profile, $_xhprof['namespace'], null, $_xhprof); } register_shutdown_function('record');
  • 7. Interpreting data ● Gui tool Xhprof UI: ○ Looks dated. ○ “Interesting” code. ○ Works well! ● Others: ○ xhprof.io ○ xhgui
  • 8. Demo time ● Siege. ● Hardest hit, most expensive. ● Plot over time. ● Compare two runs. ● Call graphs!!!
  • 9. Disclaimer ● Siege isn’t really profiling the “real” world. ● Be careful not to DOS production... ● xhprof can be run in production (I haven’ t).
  • 10. @_massey Questions?