Website performance testing from the command line

There are various commands you can use in the terminal to quickly identify a website’s TTFB, page size, and other load times. Some require the installation of various command line libraries or package managers.


curl -s -w 'Testing Website Response Time for :%\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nAppCon Time:\t\t%{time_appconnect}\nRedirect Time:\t\t%{time_redirect}\nPre-transfer Time:\t%{time_pretransfer}\nStart Time (TTFB):\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null

Curl trace-time

curl --trace-time -v -o /dev/null

Get site cookies

Install PhantomJS: brew cask install phantomjs
Download fetch_data.js here ยป

phantomjs --ignore-ssl-errors=yes --disk-cache=yes /path/to/fetch_data.js

Page Speed Insights from the command line
Install with npm: npm install –global psi


You can also filter the results for either desktop or mobile views:

psi --strategy=desktop
psi --strategy=mobile

GTMetrix reports from the command line

Run the test:

curl --user <gtm-account-email>:<gtm-api-key> --form url= --form x-metrix-adblock=0

Get the results of the test:

curl --user <gtm-account-email>:<gtm-api-key>{testID} | python -m json.tool


Install with homebrew: brew install homebrew/apache/ab
Note that the trailing slash at the end of the domain is important. You will get an error if it’s not there.

ab -n 100


nghttp -nys