This document discusses profiling PHP applications. It defines profiling as dynamic program analysis that measures things like memory and CPU usage. It covers both static analysis tools that analyze code structure and dynamic profilers like Xdebug and XHProf that gather data by executing programs. Xdebug and XHProf are introduced as common profiling extensions for PHP. XHProf is highlighted as a lightweight passive profiler with a web GUI called XHGui for reviewing profiling data. Profiling is presented as useful for debugging performance issues and gaining insight into an application's behavior.
3. WIKIPEDIA
profiling is aform of dynamicprogramanalysis thatmeasures,
for example, the space (memory) or time complexityof a
program, the usage of particular instructions, or the frequency
and durationof functioncalls. Mostcommonly, profiling
information serves to aid program optimization.
7. WIKIPEDIA
Staticprogramanalysis is the analysis of computer software that
is performed without actuallyexecuting programs
The term is usuallyapplied to the analysis performed byan
automated tool, with human analysis beingcalled program
understanding, program comprehension or code review.
8. STATIC ANALYSIS TOOLS
There are asetof tools which perform static code analysis.
These tools can be integrated within an automated build.
PHP Mess Detector
PHP Copy/Paste Detector
PHP CodeSniffer
PHP Dead Code Detector
There is anice page containingapredefined setof tools for a
build to be found atJenkins PHP
12. WIKIPEDIA
The analysis of computer software thatis performed by
executing programs ona real or virtual processor.
For dynamic program analysis to be effective,
the targetprogram mustbe executed with sufficient test inputs
to produce interestingbehavior.
Use of software testingmeasures such as code coverage helps
ensure thatan adequate slice of the program's setof possible
behaviors has been observed.
13. CALLSTACK
Acallstack is the order in which statements are exectuted.
An example commonlyknown, is an exceptiontrace. This trace
shows allthe statements executed before an exception is
thrown.
14. CALLGRAPH
Acallgraph is avisual representationof acallstack.
In large applications this graph can give you better insight on how
an application is wired.
15. PROFILING DATA
Usually, the datagathered with aprofiler can be represented in
stacks or graphs.
Theycan include information regardingmemory- and cpu-usage.
18. REASONS
We live in adigitalage where we wanteverythinginstantly.
Accordingto a , 51 percentof online
shoppers in the U.S claimed if asite is too slow theywillnot
complete apurchase.
Nowadays, search engine indexingalso accounts for page load.
case studyfrom Radware
Thepsychologyofwebperformance
SEO101:Howimportantissitespeedin2014?
CasestudyfromRadware
23. ACTIVE PROFILER
Used duringdevelopment
Gather more information than passive profilers
(like variables/values)
Performance impactis bigger
Should _NOT_be used in production
Example: Xdebug
26. XDEBUG
Generates files (like Valgrind for C)
Can be analysed byKCacheGrind amongothers
Cachegrind files are relativelybigin size
Also adeveloper toolfor breakpoints and remote debugging
Active profiler
cachegrind
34. XHPROF
Developed byFacebook and released as open-source in 2009
PECL extension
Lightweightfor beingapassive profiler
Includes webguifor reviewingand comparingprofilingdata
50. LINK0/PROFILER
Focused on XHProf
Has multiple persistence layers for storingprofiles
Memory
Flysystem
ZendDbAdapter
MongoDB(work in progress)
Available on composer/packagist
FullyObject-orientated
100%code coverage
http://github.com/link0/profiler
53. SOME IDEAS
Enable on production with sampling
Aggregate allprofiles to centralized machine/cluster
Integrate into continuous deployment
Run profilingon acceptance environment
Alertwhen compared differences surpass threshold
Codeception integration
Find business use-cases thatare slow
Make acase for refactoringto the business
Focus on the customers emulated experience
55. QUESTIONS? I <3 FEEDBACK
Joind.in:
GitHub:
Twitter:
IRC: link0 on Freenode
https://joind.in/talk/view/13420
http://github.com/dennisdegreef
@dennisdegreef
SLIDES ARE ALSO ON JOIND.IN
56. USEFUL LINKS
ProfilingPHP with PhpStorm and Xdebug
ProfilingPHP with PhpStorm and Zend Debugger
XDebugProfiler documentation
XHProf PHP documentation
Profilingwith XHProf and XHGui
http://github.com/link0/profiler