Magento Meetup New Delhi- Performance Optimization

Preview:

Citation preview

Performance OptimizationJitendra SinghSoftware Engineer

Why performance

is so important

40% of users leave a website that take more than 3 seconds to load

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

Performance Testing Tools

1.Xdebug

2.KCachegrind

3.Xhprof

4.Blackfire etc.

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.

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)

Triggering Blackfire Profile

1.Blackfire Companion (Google Chrome extension)

2.Blackfire Client (CLI)

**Logos and Trademarks are owned by their respective owners

**Logos and Trademarks are owned by their respective owners

**Logos and Trademarks are owned by their respective owners

**Logos and Trademarks are owned by their respective owners

Profile Ajax Request

**Logos and Trademarks are owned by their respective owners

**Logos and Trademarks are owned by their respective owners

**Logos and Trademarks are owned by their respective owners

**Logos and Trademarks are owned by their respective owners

**Logos and Trademarks are owned by their respective owners

Profiling CLI commands

1. $ blackfire --samples 10 run php my-script.php2. $ blackfire --reference=7 run php my-script.php3. $ blackfire --json run php my-script.php

Profiling part of your

code

1. $blackfire = new \Blackfire\Client();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);

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"

Writing Assertion

Testing with custom metrics

Thanks

Recommended