Agenda
- Motivation
- Explanation of terms
- Deep Dive Profiler
- Pitfalls
Why
profiling?
Time
is
money
Detect
Bottlenecks
DB
, Filesystem
, API
, Bad code
80-20
rule
Agenda
- Motivation
- Explanation of terms
- Deep Dive Profiler
- Pitfalls
Callers, Callees, Call Graph
Oh My ...
Callers
calls the function
Callees
called
by the function
info about
execution time, function calls
& memory
Call graph
hierarchical visualisation
of function calls
How to
profile?
sort by
exclusive time
sort by
function calls
Profiling
vs.
Bench
marking
Profiling
relative
performance
Agenda
- Motivation
- Explanation of terms
- Deep Dive Profiler
- Pitfalls
History
Zend
(Server)
Z-Ray
Realtime
analysis
in Browser
DB Queries
, Filter / Sort
Execution Time
, Request info
Erros / Exceptions
Plugins
are
awesome
written in plain PHP
zray.php
<?php
// Allocate ZRayExtension for namespace "doctrine2"
$zre = new \ZRayExtension('doctrine2', true);
// Doctrine\DBAL
$zre->traceFunction(
'Doctrine\DBAL\Connection::execute', // <-- analyze this
function(){ /* before */ },
function(){ /* after */}
);
// rendering via phtml files
Z-Ray Doctrine 2 Plugin
SensioLabs
Blackfire
Interactive
Call Graph
with
Different
visualizations
Time, I/O Wait, CPU Time, Memory, Network, (HTTP, SQL)
Comparing
of
profiles
PHP SDK available
<?php
// start profiling
$blackfire = new Blackfire\Client(
new \Blackfire\ClientConfiguration($clientId, $clientToken)
);
$probe = $blackfire->createProbe();
// user application code ...
// end profiling
$blackfire->endProbe($probe);
PHPUnit, Guzzle and Goutte integration
Much more
features
in paid version
Tideways
Timeline
Tracing
and
Customization
detailed
Call graph
Application
Performance
Monitoring
Custom Instrumentation
Transaction names, Collecting timespans
Metadata to root spans, Detecting Exceptions
extension API example
<?php
// Collecting Timespans
$span = \Tideways\Profiler::createSpan('sql');
$span->startTimer();
$span->annotate(array('title' => 'insert users'));
$pdo->query('INSERT INTO users (id, name) values (1, "foo")');
$span->stopTimer();
// wrap spans around function calls
\Tideways\Profiler::start();
\Tideways\Profiler::watch('Acme\Library::doSomething');
Error tracking
Alerts and Notifications
Agenda
- Motivation
- Explanation of terms
- Deep Dive Profiler
- Pitfalls
Pitfalls
Profiiling overhead
More details
Micro
optimizations
Not
to change
technology