SlideShare a Scribd company logo
1 of 10
Download to read offline
Profiling with XHProf
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...
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.
Collecting profile data
● Enable:
○ xhprof_enable($flags);
● Collect:
○ $data = xhprof_disable();
● Globally:
○ .htaccess &/or php.ini
○ auto_prepend_file = “header.php”;
○ auto_append_file = “footer.php”;
Collecting profile data
<?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');
Interpreting data
● Gui tool Xhprof UI:
○ Looks dated.
○ “Interesting” code.
○ Works well!
● Others:
○ xhprof.io
○ xhgui
Demo time
● Siege.
● Hardest hit, most expensive.
● Plot over time.
● Compare two runs.
● Call graphs!!!
Disclaimer
● Siege isn’t really profiling the “real”
world.
● Be careful not to DOS production...
● xhprof can be run in production (I haven’
t).
@_massey
Questions?

More Related Content

What's hot

Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonbСтажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonbSmartTools
 
PHP and Databases
PHP and DatabasesPHP and Databases
PHP and DatabasesThings Lab
 
Chap 5 php files part-2
Chap 5 php files   part-2Chap 5 php files   part-2
Chap 5 php files part-2monikadeshmane
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introductionTse-Ching Ho
 
PHP Programming: Intro
PHP Programming: IntroPHP Programming: Intro
PHP Programming: IntroThings Lab
 
Cache'owanie danych w PHP
Cache'owanie danych w PHPCache'owanie danych w PHP
Cache'owanie danych w PHPPatryk Jar
 
File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?Christian Kauhaus
 
MongoDB: How it Works
MongoDB: How it WorksMongoDB: How it Works
MongoDB: How it WorksMike Dirolf
 
5分で始める XS - tsukuba.xs#1
5分で始める XS - tsukuba.xs#15分で始める XS - tsukuba.xs#1
5分で始める XS - tsukuba.xs#1Yuji Shimada
 
Accessing data from a simple post by karan chanana
Accessing data from a simple post by karan chananaAccessing data from a simple post by karan chanana
Accessing data from a simple post by karan chananakaran chanana
 

What's hot (16)

Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonbСтажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
 
Php talk
Php talkPhp talk
Php talk
 
PHP and Databases
PHP and DatabasesPHP and Databases
PHP and Databases
 
Chap 5 php files part-2
Chap 5 php files   part-2Chap 5 php files   part-2
Chap 5 php files part-2
 
C99[2]
C99[2]C99[2]
C99[2]
 
17 sessions
17 sessions17 sessions
17 sessions
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introduction
 
Dc kyiv2010 jun_08
Dc kyiv2010 jun_08Dc kyiv2010 jun_08
Dc kyiv2010 jun_08
 
PHP Programming: Intro
PHP Programming: IntroPHP Programming: Intro
PHP Programming: Intro
 
Cache'owanie danych w PHP
Cache'owanie danych w PHPCache'owanie danych w PHP
Cache'owanie danych w PHP
 
File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?
 
MongoDB: How it Works
MongoDB: How it WorksMongoDB: How it Works
MongoDB: How it Works
 
extending-php
extending-phpextending-php
extending-php
 
Sahu
SahuSahu
Sahu
 
5分で始める XS - tsukuba.xs#1
5分で始める XS - tsukuba.xs#15分で始める XS - tsukuba.xs#1
5分で始める XS - tsukuba.xs#1
 
Accessing data from a simple post by karan chanana
Accessing data from a simple post by karan chananaAccessing data from a simple post by karan chanana
Accessing data from a simple post by karan chanana
 

Viewers also liked

Your Team Is Frustraited
Your Team Is FrustraitedYour Team Is Frustraited
Your Team Is FrustraitedRashi Gupta
 
Etoquette ba 381_presentation_use_this_one
Etoquette ba 381_presentation_use_this_oneEtoquette ba 381_presentation_use_this_one
Etoquette ba 381_presentation_use_this_oneShaolins Prem
 
Why is internet’s Democracy Rebirth so Sexy?
Why is internet’s Democracy Rebirth so Sexy?Why is internet’s Democracy Rebirth so Sexy?
Why is internet’s Democracy Rebirth so Sexy?Tomislav Korman
 
Projekt E- građani: Središnji državni portal
Projekt E- građani: Središnji državni portalProjekt E- građani: Središnji državni portal
Projekt E- građani: Središnji državni portalTomislav Korman
 
pre launch project in Bhiwadi 9717762246
pre launch project in Bhiwadi 9717762246pre launch project in Bhiwadi 9717762246
pre launch project in Bhiwadi 9717762246Adore Global Pvt. Ltd
 
Comparison contrast
Comparison contrastComparison contrast
Comparison contrastLes Davy
 
MBA724 s6 w1 experimental design
MBA724 s6 w1 experimental designMBA724 s6 w1 experimental design
MBA724 s6 w1 experimental designRachel Chung
 
47553 c52 14fc-4397-89eca7539c013374
47553 c52 14fc-4397-89eca7539c01337447553 c52 14fc-4397-89eca7539c013374
47553 c52 14fc-4397-89eca7539c013374Carlos Carvalho
 
Definition of Matter Lab + Phase Change- Day 2
Definition of Matter Lab + Phase Change- Day 2Definition of Matter Lab + Phase Change- Day 2
Definition of Matter Lab + Phase Change- Day 2jmori1
 
CSS3 Transitions
CSS3 TransitionsCSS3 Transitions
CSS3 Transitionshstryk
 
Real HCG Drops For Real Benefits
Real HCG Drops For Real BenefitsReal HCG Drops For Real Benefits
Real HCG Drops For Real Benefitssocialbook
 

Viewers also liked (20)

Your Team Is Frustraited
Your Team Is FrustraitedYour Team Is Frustraited
Your Team Is Frustraited
 
Corespring
CorespringCorespring
Corespring
 
Etoquette ba 381_presentation_use_this_one
Etoquette ba 381_presentation_use_this_oneEtoquette ba 381_presentation_use_this_one
Etoquette ba 381_presentation_use_this_one
 
Why is internet’s Democracy Rebirth so Sexy?
Why is internet’s Democracy Rebirth so Sexy?Why is internet’s Democracy Rebirth so Sexy?
Why is internet’s Democracy Rebirth so Sexy?
 
Projekt E- građani: Središnji državni portal
Projekt E- građani: Središnji državni portalProjekt E- građani: Središnji državni portal
Projekt E- građani: Središnji državni portal
 
pre launch project in Bhiwadi 9717762246
pre launch project in Bhiwadi 9717762246pre launch project in Bhiwadi 9717762246
pre launch project in Bhiwadi 9717762246
 
Gao report
Gao reportGao report
Gao report
 
Comparison contrast
Comparison contrastComparison contrast
Comparison contrast
 
อติมา อุ่นจิตร
อติมา  อุ่นจิตรอติมา  อุ่นจิตร
อติมา อุ่นจิตร
 
MBA724 s6 w1 experimental design
MBA724 s6 w1 experimental designMBA724 s6 w1 experimental design
MBA724 s6 w1 experimental design
 
47553 c52 14fc-4397-89eca7539c013374
47553 c52 14fc-4397-89eca7539c01337447553 c52 14fc-4397-89eca7539c013374
47553 c52 14fc-4397-89eca7539c013374
 
บทที่ 11
บทที่ 11บทที่ 11
บทที่ 11
 
Definition of Matter Lab + Phase Change- Day 2
Definition of Matter Lab + Phase Change- Day 2Definition of Matter Lab + Phase Change- Day 2
Definition of Matter Lab + Phase Change- Day 2
 
Guide leaving your small business
Guide leaving your small businessGuide leaving your small business
Guide leaving your small business
 
CSS3 Transitions
CSS3 TransitionsCSS3 Transitions
CSS3 Transitions
 
Tebak Gambar
Tebak GambarTebak Gambar
Tebak Gambar
 
Ms word shortcut keys
Ms word shortcut keysMs word shortcut keys
Ms word shortcut keys
 
Real HCG Drops For Real Benefits
Real HCG Drops For Real BenefitsReal HCG Drops For Real Benefits
Real HCG Drops For Real Benefits
 
S t o r y b o a r d
S t o r y b o a r dS t o r y b o a r d
S t o r y b o a r d
 
Sportovi vo uk mapi
Sportovi vo uk   mapiSportovi vo uk   mapi
Sportovi vo uk mapi
 

Similar to Profiling with Xhprof

2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappersPositive Hack Days
 
Fun with processes - lightning talk
Fun with processes - lightning talkFun with processes - lightning talk
Fun with processes - lightning talkPaweł Dawczak
 
Out of the Box Replication in Postgres 9.4(pgconfsf)
Out of the Box Replication in Postgres 9.4(pgconfsf)Out of the Box Replication in Postgres 9.4(pgconfsf)
Out of the Box Replication in Postgres 9.4(pgconfsf)Denish Patel
 
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Francisco José Seva Mora
 
Hadoop installation on windows
Hadoop installation on windows Hadoop installation on windows
Hadoop installation on windows habeebulla g
 
02 Hadoop deployment and configuration
02 Hadoop deployment and configuration02 Hadoop deployment and configuration
02 Hadoop deployment and configurationSubhas Kumar Ghosh
 
How to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHubHow to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHubTiago Simões
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from githubAntony Gitomeh
 
PSR-7 and PSR-15, why can't you ignore them
PSR-7 and PSR-15, why can't you ignore themPSR-7 and PSR-15, why can't you ignore them
PSR-7 and PSR-15, why can't you ignore themSérgio Rafael Siqueira
 
Make PHP Extension
Make PHP ExtensionMake PHP Extension
Make PHP ExtensionNyo Chou
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 

Similar to Profiling with Xhprof (20)

PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
Creating a phar
Creating a pharCreating a phar
Creating a phar
 
EC CUBE 3.0.x installation guide
EC CUBE 3.0.x installation guideEC CUBE 3.0.x installation guide
EC CUBE 3.0.x installation guide
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
PHP Profiling/performance
PHP Profiling/performancePHP Profiling/performance
PHP Profiling/performance
 
Hadoop 2.4 installing on ubuntu 14.04
Hadoop 2.4 installing on ubuntu 14.04Hadoop 2.4 installing on ubuntu 14.04
Hadoop 2.4 installing on ubuntu 14.04
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
 
Xdebug from a to x
Xdebug from a to xXdebug from a to x
Xdebug from a to x
 
Fun with processes - lightning talk
Fun with processes - lightning talkFun with processes - lightning talk
Fun with processes - lightning talk
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
Out of the Box Replication in Postgres 9.4(pgconfsf)
Out of the Box Replication in Postgres 9.4(pgconfsf)Out of the Box Replication in Postgres 9.4(pgconfsf)
Out of the Box Replication in Postgres 9.4(pgconfsf)
 
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
 
Hadoop installation on windows
Hadoop installation on windows Hadoop installation on windows
Hadoop installation on windows
 
02 Hadoop deployment and configuration
02 Hadoop deployment and configuration02 Hadoop deployment and configuration
02 Hadoop deployment and configuration
 
How to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHubHow to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHub
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from github
 
PSR-7 and PSR-15, why can't you ignore them
PSR-7 and PSR-15, why can't you ignore themPSR-7 and PSR-15, why can't you ignore them
PSR-7 and PSR-15, why can't you ignore them
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 
Make PHP Extension
Make PHP ExtensionMake PHP Extension
Make PHP Extension
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 

Recently uploaded

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

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).