Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Profiling PHP @ PHPers Warszawa #12
Search
Sebastian Grodzicki
October 10, 2016
Technology
92
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Profiling PHP @ PHPers Warszawa #12
Sebastian Grodzicki
October 10, 2016
More Decks by Sebastian Grodzicki
See All by Sebastian Grodzicki
Fault-tolerant workflow orchestration in PHP @ PHPCon Poland 2024
sgrodzicki
0
180
PHP w Google Cloud @ PHPCon Poland 2022
sgrodzicki
0
51
Elasticsearch + Symfony @ SymfonyLive Online Polish Edition 2021
sgrodzicki
0
200
Elasticsearch + Symfony @ WDI 2021
sgrodzicki
0
67
Combining Logs, Metrics, and Traces for Unified Observability @ Infoshare 2020
sgrodzicki
0
560
Building Distributed Systems in Distributed Teams @ Infoshare 2020
sgrodzicki
0
96
Building Distributed Systems in Distributed Teams @ 4Developers 2020
sgrodzicki
0
95
Building Distributed Systems in Distributed Teams @ DevOpsDay Warsaw 2019
sgrodzicki
0
77
Infrastructure as Code @ DevOpsDay Warsaw 2019
sgrodzicki
0
100
Other Decks in Technology
See All in Technology
【GCC2026】大規模言語モデルを活用した内製検索サービスの社内展開や業務活用
bandainamcostudios
PRO
0
390
社内の7割が使うデータ基盤を、 データチーム2人で回すためにやったこと
koh_yoshi
4
1.5k
My broken English still works: speaking at global OSS events
naruoga
0
120
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
関東Kaggler会発表資料
takoi
1
280
【GCC2026】鉄拳8でのVFX開発事例
bandainamcostudios
PRO
0
160
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
260
[potatotips #96] Give Your AI Agent the Flutter Playbook
korodroid
0
130
私がブラウザを自作したくなった理由
supurazako
1
280
型落ちシンクライアント端末のPoEモジュールを自作したかった話
logica0419
0
140
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
コーチングの奥義 何もしないテクニック
jinwatanabe
0
140
Featured
See All Featured
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
390
Mind Mapping
helmedeiros
PRO
1
330
The Pragmatic Product Professional
lauravandoore
37
7.4k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Designing Powerful Visuals for Engaging Learning
tmiket
1
500
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Site-Speed That Sticks
csswizardry
13
1.5k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Prompt Engineering for Job Search
mfonobong
0
410
Mobile First: as difficult as doing things right
swwweet
225
10k
Docker and Python
trallard
47
4.1k
Transcript
PROFILING PHP SEBASTIAN GRODZICKI
WHO WAS AT PHPCON?
SEBASTIAN GRODZICKI CTO @ SHOWROOM
40% OF USERS ABANDON A WEBSITE THAT TAKES MORE THAN
3 SECONDS TO LOAD Akamai STATISTICS
PROFILING IS A WAY TO MEASURE WHERE A PROGRAM SPENDS
TIME MathWorks DEFINITION
MICROTIME
Xdebug
xdebug.profiler_enable_trigger = 1 http://url?XDEBUG_PROFILE=1
KCACHEGRIND
WEBGRIND
XHProf
<?php xhprof_enable(); # do some stuff $xhprof_data = xhprof_disable();
XHPROF
None
None
PROFILING PHP TIME Wall time I/O CPU Disk I/O Network
= = + +
PROFILING PHP INCLUSIVE VS EXCLUSIVE TIME function foo() { $str
= bar(); return $str; } function foo() { $str = bar(); return $str; }
BLACKFIRE CONTINUOUS PERFORMANCE TESTING
BLACKFIRE CALLGRAPHS
BLACKFIRE HOT PATHS
DEMO CHROME COMPANION
None
None
public function getVersion() { $process = new Process($this->getPath() . '
--version'); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $version = substr($process->getOutput(), 12); return trim($version); }
public function getVersion() { static $version; if (null !==
$version) { return trim($version); } $process = new Process($this->getPath() . ' --version'); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $version = substr($process->getOutput(), 12); return trim($version); }
None
DEMO BLACKFIRE CURL
None
None
DEMO BLACKFIRE RUN
None
None
ASSERTIONS
PROFILING PHP ASSERTIONS tests: "Application should never hit the DB":
path: "/.*" assertions: - "metrics.sql.queries.count == 0"
PROFILING PHP ASSERTIONS tests: "Homepage should never call the API":
path: "/" assertions: - "metrics.http.requests.count == 0"
PROFILING PHP ASSERTIONS tests: "Pages should be fast enough": path:
"/.*" assertions: - "main.wall_time < 100ms"
None
BUILDS
None
None
None
PHP SDK
BLACKFIRE PHP SDK ▸ composer require blackfire/php-sdk ▸ $blackfire =
new \Blackfire\Client(); ▸ $probe = $blackfire->createProbe(); ▸ $profile = $blackfire->endProbe($probe);
PHPUNIT
<?php use Blackfire\Bridge\PhpUnit\TestCaseTrait; use Blackfire\Profile; class IntegrationTest extends
\PHPUnit_Framework_TestCase { use TestCaseTrait; /** * @requires extension blackfire */ public function testSomething() { $config = new Profile\Configuration(); $config ->assert('metrics.sql.queries.count < 5', 'SQL queries') ->assert('metrics.twig.render.count < 3', 'Rendered Twig templates') ->assert('metrics.twig.compile.count == 0', 'Twig compilation') ; } }
blackfire.io/docs/24-days
QUESTIONS?
THANK YOU!