Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Profiling PHP @ PHPers Warszawa #12
Search
Sebastian Grodzicki
October 10, 2016
Technology
93
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
58
Elasticsearch + Symfony @ SymfonyLive Online Polish Edition 2021
sgrodzicki
0
200
Elasticsearch + Symfony @ WDI 2021
sgrodzicki
0
77
Combining Logs, Metrics, and Traces for Unified Observability @ Infoshare 2020
sgrodzicki
0
570
Building Distributed Systems in Distributed Teams @ Infoshare 2020
sgrodzicki
0
100
Building Distributed Systems in Distributed Teams @ 4Developers 2020
sgrodzicki
0
100
Building Distributed Systems in Distributed Teams @ DevOpsDay Warsaw 2019
sgrodzicki
0
79
Infrastructure as Code @ DevOpsDay Warsaw 2019
sgrodzicki
0
110
Other Decks in Technology
See All in Technology
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
120
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
160
スプシの手作業からの解脱 ~更新はClaude Codeに、見せ方と使い方はGASアプリに任せる~
kentarofujii
0
150
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
230
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
580
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
170
WasmをRustにする
sansantech
PRO
0
250
オントロジーって 結局なにもの? AI エージェントに「意味」を渡す知識設計の話
greenmidori
0
190
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
140
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
150
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
730
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
130
Featured
See All Featured
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Code Review Best Practice
trishagee
74
20k
Paper Plane
katiecoart
PRO
5
54k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
460
How to make the Groovebox
asonas
2
2.5k
Code Reviewing Like a Champion
maltzj
529
40k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
GitHub's CSS Performance
jonrohan
1033
470k
The Cult of Friendly URLs
andyhume
79
7k
Six Lessons from altMBA
skipperchong
29
4.5k
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!