Skip to content

Instantly share code, notes, and snippets.

@nerrad
Created July 19, 2019 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerrad/bb2d74baf6c27b47943cc0fe58f75139 to your computer and use it in GitHub Desktop.
Save nerrad/bb2d74baf6c27b47943cc0fe58f75139 to your computer and use it in GitHub Desktop.
Evaluating WordPress load time via command line

The commands on this page are useful for measuring php response times etc for your WordPress installation via commandline. This gives useful info to help debug issues at the php level separate from the http routes.

I'm pretty sure I didn't come up with this, but I have shared it in a few different places so just adding it to my personal gist repo for reference.

Create the base script

Create a script (name it whatever you want, something like t.php should suffice) in the root directory of your wp install (i.e. the same directory as the wp-config.php and main index.php file for WP. You can substitue whatever you want in the $_SERVER['REQUEST_URI'] to test different pages if you want.

<?php
$_SERVER['HTTP_HOST'] = 'eventsmart.com';
$_SERVER['REQUEST_URI'] = '/pricing/';
$_SERVER['HTTPS'] = 'on';
include 'index.php';

To Test response/build time

time php t.php

Where t.php is the name of the script you created in the initial step.

To get a list of all the queries run to generate the indicated page.

strace -s 200 -o /dev/stdout php t.php | grep sendto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment