Tool it Up! - Session #1 - Xhprof
Upcoming SlideShare
Loading in...5
×
 

Tool it Up! - Session #1 - Xhprof

on

  • 265 views

 

Statistics

Views

Total Views
265
Views on SlideShare
265
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

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

    Tool it Up! - Session #1 - Xhprof Tool it Up! - Session #1 - Xhprof Presentation Transcript

    • Date: 2013-08-01 By: gabe.
    • Xhprof - • "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil” - Knuth – err, Hoare – err, no idea.
    • History • Developed at “the facebook” • Code still maintained: https://github.com/facebook/xhprof • Docs, not so much: http://web.archive.org/web/20110514095512 /http://mirror.facebook.net/facebook/xhprof/ doc.html
    • Install • wget https://github.com/facebook/xhprof/archive/master.zip unzip master.zip cd xhprof-master/extension phpize ./configure make sudo make install •
    • Enable in PHP ● To use xhprof, you need to tell your php code that you want to profile it: php.ini is the easiest: php_value auto_prepend_file "../../xhprof/external/header.php" php_value auto_append_file "../../xhprof/external/footer.php"
    • Or... you can enable on a case by case basis using: <?php xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); for ($i = 0; $i <= 1000; $i++) { $a = $i * $i; } $xhprof_data = xhprof_disable(); $XHPROF_ROOT = "/tools/xhprof/"; include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php"; include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php"; $xhprof_runs = new XHProfRuns_Default(); $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_testing"); echo "http://localhost/xhprof/xhprof_html/index.php? run={$run_id}&source=xhprof_testingn";
    • Basic Usage • Just load a page • Small link will appear on bottom • Click!
    • What the output means • Inclusive Time: Time spent in this function + called functions • Exclusive Time: Time spent in this function only • Wall Time: Time between when something started + finished as measured by the clock on the wall • CPU Time: Time spent in user space + kernel space (doesn't include IO)
    • What the output means • Inclusive Time: Time spent in this function + called functions • Exclusive Time: Time spent in this function only • Wall Time: Time between when something started + finished as measured by the clock on the wall • CPU Time: Time spent in user space + kernel space (doesn't include IO)
    • Contrived Examples • sleep(10); • http://gguzman.gamma.net/rsrc/sleep.txt • High wall time • Low CPU time
    • Contrived Examples (cont) • fib(30); • http://gguzman.gamma.net/rsrc/fibonacci.txt • High wall time • High CPU time
    • Real Example • Td3x.com http://gguzman.gamma.net/rsrc/xhprofio/?xhprof[tem
    • Trends • Xhprof.io
    • Caveats • Can get resource intensive, especially on VM. • Don't use with XDEBUG • OK to use in production, but maybe not all the time... flag to enable, or enable on a per server basis to collect data sometimes.
    • Questions
    • Thanks