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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Sebastian Grodzicki
October 10, 2016
Technology
97
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
Transcript
48 slides
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!
More Decks by Sebastian Grodzicki
See All by Sebastian Grodzicki
Fault-tolerant workflow orchestration in PHP @ PHPCon Poland 2024
sgrodzicki
0
190
PHP w Google Cloud @ PHPCon Poland 2022
sgrodzicki
0
65
Elasticsearch + Symfony @ SymfonyLive Online Polish Edition 2021
sgrodzicki
0
210
Elasticsearch + Symfony @ WDI 2021
sgrodzicki
0
83
Combining Logs, Metrics, and Traces for Unified Observability @ Infoshare 2020
sgrodzicki
0
580
Building Distributed Systems in Distributed Teams @ Infoshare 2020
sgrodzicki
0
110
Building Distributed Systems in Distributed Teams @ 4Developers 2020
sgrodzicki
0
110
Building Distributed Systems in Distributed Teams @ DevOpsDay Warsaw 2019
sgrodzicki
0
85
Infrastructure as Code @ DevOpsDay Warsaw 2019
sgrodzicki
0
110
Other Decks in Technology
See All in Technology
OpenTelemetryで変わった 新時代のCloudWatchメトリクス監視
tsukuboshi
0
500
Platform Engineering をベースとした Agentic Software Factory の実践
110y
3
910
Go でトランザクション、どう書いてますか?
knwoop
1
560
「正しいデータ」の定義をAI エージェントとつくるGoogleADKによるデータ品質定義の実践
takaha4k
0
110
HTTP通信に使おうとすると実はめんどくさいfile_get_contents
maguroalternative
0
260
Is the Website Dying?
miriamschwab
0
130
20261119_AgentCore
takuyay0ne
1
210
AWS Client VPNの設定でハマったポイントとその過程での気づき
amarelo_n24
1
430
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
7.5k
Taking back control of your AI development
inesmontani
PRO
0
310
農家は秘伝のタレを知らない - NOBODY KNOWS THE HIDDEN SOURCE - Kaggriculture 3rd Place Solution
masspeaks
3
680
AI-Ready なデータ基盤ってなに? & 新卒未経験が、いま考えていること
imuta
0
1.1k
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
360
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.7k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
380
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Context Engineering - Making Every Token Count
addyosmani
9
1.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
580
Reality Check: Gamification 10 Years Later
codingconduct
0
2.4k
The SEO Collaboration Effect
kristinabergwall1
1
630
The Curse of the Amulet
leimatthew05
4
17k