Book Image

Instant Magento Performance Optimization How-to

By : Nayrolles Mathieu (USD), Mathieu Nayrolles
Book Image

Instant Magento Performance Optimization How-to

By: Nayrolles Mathieu (USD), Mathieu Nayrolles

Overview of this book

The optimization of an attractive commercial website is a non-trivial task that demands time and knowledge. Optimization is a critical point for all growing businesses because a misconfiguration could make you lose money, a lot of money. If your server is overloaded, a browser that wants to turn into a buyer will not be able to, and you will lose customers. "Instant Magento Performance Optimization How-To" is a practical, hands-on guide that provides you with a number of clear, step-by-step exercises to help you reach a high performance level for your Magento stores and keep your customers satisfied.This book looks at tweaks and tips used to boost your Magento Performance, and breaks down the confusion that surrounds the subject.You will learn how to compress your pages, styles, and scripts by almost 80%. We will also take a look at controversial optimization settings such as Magento core compilation or enabling all caching systems. You will discover new applications that improve performance. If you wish your e-businesses to grow and want to keep your customers satisfied, you definitely need this book.
Table of Contents (7 chapters)

Using the Profiler (Should know)


Magento embeds a library to profile your Magento and detect some performance issues. In this recipe, we will see how to use it.

How to do it...

  1. Activate the Profiler by navigating to System | Configuration | Advanced | Developer | Debug.

  2. The second step is to enable the debugger in YOUR_STORE.COM/index.php near line 71 and remove the sharp so that it looks like the following:

    Varien_Profiler::enable();

    If you can't find this line anywhere, add it somewhere before the last line (Mage::run($mageRunCode, $mageRunType);). If you have successfully enabled the profile, all your web pages will have a new footer similar to the following:

How it works...

The table in your footer contains five columns; the first one, Code Profiler, contains your timer name associated to the second column, Time, which is the time when this timer has been reached. The third column, Cnt, counts the number of times you launch the same timer. Finally, the last two columns, Emalloc and RealMem stand for the amount of memory allocated to PHP. The difference between those two is that the parameter true is passed to the second one and is not passed to the first one.

The most important column to look at is the Cnt column, because it counts the number of instances of a specific object. And to instantiate an object is time consuming. A high number in the Cnt columns could mean that you made customizations that led to unnecessary object instantiations.

There's more...

Using the built-in timers can be enough, but for an effective debug you should use your own.

Adding your own timer

In addition to the native information provided by the Profiler, you can add your own timer. In order to do this, open the file you want to monitor and add the following statements:

Varien_Profiler::start('my_timer');
[some suspicious php code]
Varien_Profiler::stop('my_timer');