Measuring WordPress speed

Improving the performance of WordPress sites is a popular topic among WordPress developers. E-commerce owners know that faster websites mean more conversions and more sales. Everybody hates to wait for pages that take long to load. However, the knowledge how to correctly improve the performance of WordPress sites is still surprisingly scarce.

The most basic and most central skill is how to measure the current speed of a WordPress site. Developers who don’t know how to measure the speed of their code or site, have a slim chance of making anything faster. Trying our 10 things that might (and mostly might not) improve a site is a waste of time and depends on luck of striking something that matters.

For WordPress, the most basic measurement is to time how long it takes for PHP to produce the HTML output. The most straightforward way to test any site anywhere is to use the command line tool curl. Just install the package (e.g. apt install curl in Debian based Linux machines) and run curl while printing the time_total value:

curl -s -o /dev/null -w "%{time_total}\n"

This means that the site took 123 miliseconds to load from the server to the machine running curl. To avoid the network lag between the server and your own computer, simply log into the server using ssh and run the curl to cut out all network hops in the middle.

If the WordPress site is running in a professional server environment, there will be some caching layers between the site and the world outsite. This caching layer will deliver the HTML content much faster than PHP would. To make sure you always get the response all the way from PHP, you need to burst the cache layer using the No-Pragma header (this is the same header your browser emits when you press Ctrl+F5).

curl -s -o /dev/null -w "%{time_total}\n" -H "Pragma: no-cache"

Some times the PHP execution will not be identical on every page load, or the server environment might be noisy. To make multiple measurements and get the average response time, you can use some for and awk scripting:

for i in {1..20}
 curl -so /dev/null -w "%{time_total}\n"
done | awk '{ sum += $1; n++; print $1 } END { if (n > 0) print "AVG: " sum / n; }'

AVG: 0.1378

Finally, if you have SSH access to the server and wp-cli is installed, you can disable one plugin at a time with this handy bash script snippet to see if there iss a single plugin that drastically affects the PHP page load time:

for p in $(wp plugin list --fields=name --status=active)
  echo $p
  wp plugin deactivate --skip-plugins $p
  for i in {1..5}
    curl -so /dev/null -w "%{time_total}\n" \
    -H "Pragma: no-cache"
  wp plugin activate $p 

We like to preach about WordPress performance. Making websites faster does not only make the world run more smoothly, it actually also saves computer processing power and electricity, and thus helps to save the world!

Below are the slides from WordCamp Athens where you can find more information about the topic.

Otto Kekäläinen


More reading

The six most important ways to improve information security on your WordPress site


WordPress still suffers from the reputation of being not secure. We state There are no unsecure WordPress sites, only poorly […]

Coding WordPress in style with PHPCS


Some developers wonder why it isn’t enough that the code just works? The reason is that ugly code is doomed to lead to errors.

WordCamp magic in Athens, Greece


Seravo has quite a long history supporting WordPress Communities. We have been giving speeches, sponsoring and attending different WordCamps for many […]