SlideShare une entreprise Scribd logo
1  sur  23
PHP Aberdeen
Quick optimisation
of PHP with
Webgrind
Andy Gaskell - @AndyGasman / @SSOFB
Webgrind
“Webgrind is a Xdebug profiling web frontend in PHP.
It implements a subset of the features of kcachegrind
and installs in seconds and works on all platforms. For
quick'n'dirty optimizations it does the job.”
https://github.com/jokkedk/webgrind
Introduction
Webgrind - why?
● Characterise to optimise
● No point in optimising code without characterising
● Look inside libraries
● Find the slow bits
● Understand the platforms you work on
Install xdebug
You probably don’t need to.
php 5
sudo apt-get install php5-xdebug
php 7
sudo apt-get install php-xdebug
...and maybe graphviz too
Just for the graphs really
sudo apt-get install graphviz
Enable xdebug everywhere
php 5
/etc/php5/apache2/php.ini
php 7
/etc/php/7.0/apache2/php.ini
Enable xdebug per thing
Pop it in your .ini or .htaccess like...
xdebug.profiler_enable=1
...great for a quick debug/profile of system
characterisation.
Just copy the files to
Easiest bit :)
● Download from github
● Put them in a folder under your web root
● Change the config.php if the xdebug isn’t outputting to
/tmp
Use cases?
● How can I make this bat-shit fast?
● Why is this server / system slower than the other one?
● What’s holding this up?
● How does the performance differ between library X
and Y?
Just hit it up in your browser
Just go to wherever you put the files, ie
http://localhost/webgrind or
http://dev.stuff.com/webgrind
Looking at results
Loads of info, have a tinker…
● Tweak the settings, to remove some noise
● Change the sorts
● Browse the call graph
● Compare costs
Practical example
● API experiences large slow-down with growth in data
size
● Characterised with Webgrind
Before...
Average time:
0.442942536816s
Slowest time:
13.3827910423s
After...
Average time:
0.335654691152s
Slowest time:
0.815340042114s
Tricks and tips - running
● Sometimes it can take a couple of minutes to generate
the report
● Sometimes it can crash your system if it’s doing big
stuff
● You can see the files being created to gauge size /
complexity, ie “ls -lha /tmp/cachegrind*”
● If it’s taking crazy-long, set the “show” value lower
Tricks and tips - analysing
● Call graphs are colour coded
● If you don’t like svg call graphs, you can set
“graphImageType” to “png” in webgrind/config.php
Other options
● Do it in your IDE, via xdebug remote profiler
○ PHP Storm
○ Eclipse
○ NotePad++
● Use KCachegrind / Callgrind, a Linux (KDE) profiling
App
Read more
● Webgrind website (just github)
https://github.com/jokkedk/webgrind
● Google your platform for WAMP, MAMP or NGINX
info
Any questions?
Andy Gaskell - @AndyGasman / @SSOFB
Thanks :)
Andy Gaskell - @AndyGasman / @SSOFB

Contenu connexe

Tendances

BDD for RIAs with JavaScript - Skills Matter
BDD for RIAs with JavaScript - Skills MatterBDD for RIAs with JavaScript - Skills Matter
BDD for RIAs with JavaScript - Skills Matter
Carlos Ble
 

Tendances (20)

Automate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsAutomate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.js
 
Modern web technologies
Modern web technologiesModern web technologies
Modern web technologies
 
Reactive Programming with Spring
Reactive Programming with SpringReactive Programming with Spring
Reactive Programming with Spring
 
Madison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small TeamsMadison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small Teams
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
 
Node.js
Node.jsNode.js
Node.js
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow Tools
 
Serverless
ServerlessServerless
Serverless
 
Daniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého SchizmaDaniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého Schizma
 
Power up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShiftPower up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShift
 
Confoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to startConfoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to start
 
Webpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsWebpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ Steps
 
TDC2013 - PHP - Virtualização e Provisionamento de Ambientes com Vagrant e ...
TDC2013 - PHP - Virtualização e Provisionamento de Ambientes com Vagrant e ...TDC2013 - PHP - Virtualização e Provisionamento de Ambientes com Vagrant e ...
TDC2013 - PHP - Virtualização e Provisionamento de Ambientes com Vagrant e ...
 
BDD for RIAs with JavaScript - Skills Matter
BDD for RIAs with JavaScript - Skills MatterBDD for RIAs with JavaScript - Skills Matter
BDD for RIAs with JavaScript - Skills Matter
 
PHP Conference Brasil 2013 - Virtualização e Provisionamento de Ambientes c...
PHP Conference Brasil 2013 - Virtualização e Provisionamento de Ambientes c...PHP Conference Brasil 2013 - Virtualização e Provisionamento de Ambientes c...
PHP Conference Brasil 2013 - Virtualização e Provisionamento de Ambientes c...
 
Start up day GDSC x Primdev 08/10/2021
Start up day GDSC x Primdev 08/10/2021Start up day GDSC x Primdev 08/10/2021
Start up day GDSC x Primdev 08/10/2021
 
PHP Application Performance
PHP Application PerformancePHP Application Performance
PHP Application Performance
 
Django 101
Django 101Django 101
Django 101
 
Binary God
Binary GodBinary God
Binary God
 
Scripting with NodeJS
Scripting with NodeJSScripting with NodeJS
Scripting with NodeJS
 

Similaire à PHP Aberdeen Quick optimisation of PHP with Webgrind

Creating a mature puppet system
Creating a mature puppet systemCreating a mature puppet system
Creating a mature puppet system
rkhatibi
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
Emma Jane Hogbin Westby
 
Chef on SmartOS
Chef on SmartOSChef on SmartOS
Chef on SmartOS
Eric Saxby
 

Similaire à PHP Aberdeen Quick optimisation of PHP with Webgrind (20)

Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)
 
Xdebug for Beginners
Xdebug for BeginnersXdebug for Beginners
Xdebug for Beginners
 
Riereta Node.js session 3 (with notes)
Riereta Node.js session 3 (with notes)Riereta Node.js session 3 (with notes)
Riereta Node.js session 3 (with notes)
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotCloud
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
 
Serverless? How (not) to develop, deploy and operate serverless applications.
Serverless? How (not) to develop, deploy and operate serverless applications.Serverless? How (not) to develop, deploy and operate serverless applications.
Serverless? How (not) to develop, deploy and operate serverless applications.
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
 
Fuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP SeasidesFuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP Seasides
 
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet System
 
Creating a mature puppet system
Creating a mature puppet systemCreating a mature puppet system
Creating a mature puppet system
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
 
There is something about serverless
There is something about serverlessThere is something about serverless
There is something about serverless
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
 
Introduce Django
Introduce DjangoIntroduce Django
Introduce Django
 
Ramaze - The Underrated Ruby Web Framework
Ramaze - The Underrated Ruby Web FrameworkRamaze - The Underrated Ruby Web Framework
Ramaze - The Underrated Ruby Web Framework
 
Chef on SmartOS
Chef on SmartOSChef on SmartOS
Chef on SmartOS
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
 
Xdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP codeXdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP code
 

Dernier

哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
ydyuyu
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Monica Sydney
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
F
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
JOHNBEBONYAP1
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiAbu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Monica Sydney
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
ayvbos
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
F
 

Dernier (20)

Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiAbu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
Call girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girlsCall girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girls
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 

PHP Aberdeen Quick optimisation of PHP with Webgrind

  • 1. PHP Aberdeen Quick optimisation of PHP with Webgrind Andy Gaskell - @AndyGasman / @SSOFB
  • 2. Webgrind “Webgrind is a Xdebug profiling web frontend in PHP. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.” https://github.com/jokkedk/webgrind
  • 3. Introduction Webgrind - why? ● Characterise to optimise ● No point in optimising code without characterising ● Look inside libraries ● Find the slow bits ● Understand the platforms you work on
  • 4. Install xdebug You probably don’t need to. php 5 sudo apt-get install php5-xdebug php 7 sudo apt-get install php-xdebug
  • 5. ...and maybe graphviz too Just for the graphs really sudo apt-get install graphviz
  • 6. Enable xdebug everywhere php 5 /etc/php5/apache2/php.ini php 7 /etc/php/7.0/apache2/php.ini
  • 7. Enable xdebug per thing Pop it in your .ini or .htaccess like... xdebug.profiler_enable=1 ...great for a quick debug/profile of system characterisation.
  • 8. Just copy the files to Easiest bit :) ● Download from github ● Put them in a folder under your web root ● Change the config.php if the xdebug isn’t outputting to /tmp
  • 9. Use cases? ● How can I make this bat-shit fast? ● Why is this server / system slower than the other one? ● What’s holding this up? ● How does the performance differ between library X and Y?
  • 10. Just hit it up in your browser Just go to wherever you put the files, ie http://localhost/webgrind or http://dev.stuff.com/webgrind
  • 11. Looking at results Loads of info, have a tinker… ● Tweak the settings, to remove some noise ● Change the sorts ● Browse the call graph ● Compare costs
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Practical example ● API experiences large slow-down with growth in data size ● Characterised with Webgrind
  • 18. Tricks and tips - running ● Sometimes it can take a couple of minutes to generate the report ● Sometimes it can crash your system if it’s doing big stuff ● You can see the files being created to gauge size / complexity, ie “ls -lha /tmp/cachegrind*” ● If it’s taking crazy-long, set the “show” value lower
  • 19. Tricks and tips - analysing ● Call graphs are colour coded ● If you don’t like svg call graphs, you can set “graphImageType” to “png” in webgrind/config.php
  • 20. Other options ● Do it in your IDE, via xdebug remote profiler ○ PHP Storm ○ Eclipse ○ NotePad++ ● Use KCachegrind / Callgrind, a Linux (KDE) profiling App
  • 21. Read more ● Webgrind website (just github) https://github.com/jokkedk/webgrind ● Google your platform for WAMP, MAMP or NGINX info
  • 22. Any questions? Andy Gaskell - @AndyGasman / @SSOFB
  • 23. Thanks :) Andy Gaskell - @AndyGasman / @SSOFB