When activated, the Perf Panel is displayed at the bottom of each page.
It will give you a detailed view into how fast the page loaded and where the bottlenecks might be.
What It Looks Like
The Perf Score is based on total time elapsed from of the server response to the browser’s
It includes client-side performance because ultimately it is the user experience that matters most.
How Fast Should It Be?
Research shows that after 1 second (1000 ms), users perceive an interface to be slow.
Ideally, each page would take 500 ms or less to completely load.
|1 - 500
|501 - 1000
- Server - Page Execution. The time it takes to execute the script, up until it begins to send the response to the browser.
- Network - Transfer. The time it takes to send all response bytes to the browser. This will be affected by the number of bytes and the speed of your network connection.
- Server - Peak Memory. The highest amount of memory used at any point in the execution of the script. This is largely affected by reading data from files or a database.
How to Activate
To display the perf panel at the bottom of every page, set
showPerfPanel: true in
Because this is a developer feature, it will only display if:
- You are running under the
- You are visiting from localhost IP (i.e. running the server locally).
- Your IP address matches
Adding Perf Tasks
By default, THT measures calls to built-in modules, like file and database access.
You can measure the performance of your own tasks by using the Perf module.
How to Improve Performance
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
— Donald Knuth
- Do not micro-optimize. Don’t worry about the difference between miniscule things, like
$a += 1vs.
$a = $a + 1. This is a poor use of your (human) time, and often leads to code that is harder to read.
- Think in human scale, not computer scale. Going from 2 nanoseconds to 1 nanosecond might be a 100% speed gain in an absolute sense, but is unnoticeable to humans. If you are benchmarking code by looping it 1 million times, the difference is probably too small to matter. Most page requests don’t run any single operation more than, say, 100 times.
- Instead, find the bottlenecks. This is the “hot path” — a single block of code that takes the biggest chunk of time. The Perf Panel will show you which tasks are taking the longest. You can add new tasks to the list using the
- The most common bottleneck is a database query. The most effective solution is usually to cache the query results.
- If it ain’t broke, don’t fix it. It’s tempting to constantly tweak performance, but if you’re already getting sub-second load times, you can probably move on to other tasks.
- Use THT's built-in optimizations to reduce response sizes, optimize assets, and minimize the number of requests.
- Take an honest look at whether 3rd party social and analytics widgets are worth the extra bloat. Try to remove anything that isn’t truly necessary. This is especially important now that the majority of browsing happens on mobile devices.