Profiling Slow Pages

Last edit: Jul 09, 2019
  • Contributors:
  • diana-lakatos
  • pavelloz

This guide will show you how to profile a slow page to find performance issues.

Requirements

This is an advanced tutorial. To follow it, you should be familiar with basic platformOS concepts, Liquid, the topics in the Get Started section, and tutorials related to Pages.

Steps

Profiling a page is a one-step process:

Step 1: Enable profiling for a page

Add enable_profiler: true to a YML file corresponding to the page you want to profile:

---
slug: my-slow-page
enable_profiler: true
---

{% include 'very_time_consuming_partial' %}

When the flag is set, whenever you trigger a request to the my-slow-page, two log entries will be added and accessible via the pos-cli logs command. The first one shows information about the page, the second one about the layout associated with the page. You can use this information to identify slow code and improve it.

Warning
To avoid noise, the log will include only entries which took longer than 10ms.

Warning
Try to not profile a page on production, as it can result in performance hit. If you absolutely have to, make sure to disable it right after you trigger the request to the page, to minimize the risk of leaving profiling enabled for a long period of time.

Questions?

We are always happy to help with any questions you may have.