Magento Meetup New Delhi- Performance Optimization
This slide is all about performance optimization in Magento2-
How to use Black fire?
what are the benefits of optimization?
How performance optimization can be done?
3. Measuring
Performance
1. The memory consumption
2. The number of times function
are called
3. The duration of function’s
execution
4. The number of SQL queries
5. What is
Blackfire
Blackfire is a web based
Performance
Management Solution.
Blackfire can be used at
any stage of your
application’s lifecycle:
during development, test
and production.
6. Installation
1. Install the blackfire-agent
package (sudo apt-get install blackfire-agent)
2. Configure you blackfire
credentials (sudo blackfire-agent -register)
3. Install the blackfire-agent
package (sudo apt-get install blackfire-agent)
4. Run the config command to
initialize the client (blackfire config)
5. Restart Blackfire (sudo
/etc/init.d/blackfire-agent restart)
19. Profiling
CLI commands
1. $ blackfire --samples 10 run php my-script.php
2. $ blackfire --reference=7 run php my-script.php
3. $ blackfire --json run php my-script.php
20. Profiling
part of your
code
1. $blackfire = new BlackfireClient();
2. $probe = $blackfire->createProbe();
// some PHP code you want to profile
$profile = $blackfire->endProbe($probe);
3. // store the profile UUID
$uuid = $probe->getRequest()->getUuid();
// retrieve the profile later on
$profile = $blackfire->getProfile($uuid);
21. Assertion
An assertion is an expression that
must return a Boolean (true if the
assertion succeeds,false
otherwise).
An assertion is made of metric
values, variables, operators
"main.peak_memory < 10mb"
"metrics.sql.queries.count == 0"
"main.peak_memory < vars.max_memory"