How to Test Website Loading Speed in Linux Terminal

Here are several command-line tools to test website loading speed and performance in Linux, along with examples of their usage.

Alby Andersen

Testing website loading speed via the Linux terminal can be done using several command-line tools that measure various performance metrics such as total response time, throughput, and concurrent request handling.


1. curl (Measure Connection Timings)

Installation: Preinstalled on most systems.
Use Case: Basic metrics like DNS lookup, SSL handshake, and total time.

curl -s -w "\n\nTiming Details:\n-----------------\nDNS Lookup: %{time_namelookup}\nConnect: %{time_connect}\nTLS Handshake: %{time_appconnect}\nTTFB (First Byte): %{time_starttransfer}\nTotal Time: %{time_total}\n" -o /dev/null https://example.com

Output:

Timing Details:
-----------------
DNS Lookup: 0.012s
Connect: 0.045s
TLS Handshake: 0.102s
TTFB (First Byte): 0.250s
Total Time: 0.350s
  • -o /dev/null: Discards the downloaded content (tests speed, not data).
  • Key Metrics:
  • TTFB (Time to First Byte): Server response time.
  • Total Time: Full page/content load time.

2. ab (Apache Benchmark)

Installation:

# Debian/Ubuntu
sudo apt install apache2-utils

# Fedora/RHEL
sudo dnf install httpd-tools

Use Case: Load testing with concurrent requests.

ab -n 100 -c 10 https://example.com/
  • -n 100: Send 100 total requests.
  • -c 10: Simulate 10 concurrent users.
  • Output includes requests per second, latency distribution, and error rates.

3. siege (HTTP Load Tester)

Installation:

# Debian/Ubuntu
sudo apt install siege

# Fedora
sudo dnf install siege

Use Case: Stress-test with customizable concurrency.

siege -c 20 -t 30s https://example.com
  • -c 20: 20 concurrent users.
  • -t 30s: Run for 30 seconds.
  • Outputs transaction rate, response time, and success/failure stats.

4. wget (Download Speed Test)

Installation: Preinstalled on most systems.
Use Case: Measure download speed for large files.

wget --output-document=/dev/null https://example.com/largefile.zip
  • Check the terminal output for download speed (e.g., 4.5 MB/s).

5. httpie (User-Friendly HTTP Client)

Installation:

pip install httpie

Use Case: Detailed breakdown of request phases.

http --verbose --timeout 30 --print=hH https://example.com
  • Shows timing for DNS, connection, SSL, and data transfer.

6. lighthouse (Google’s Performance Audit)

Installation: Requires Node.js.

npm install -g lighthouse

Use Case: Comprehensive performance report (SEO, speed, best practices).

lighthouse https://example.com --view --output=html --output-path=report.html
  • Generates an HTML report with scores and recommendations.

7. speedtest-cli (Network Speed Test)

Installation:

pip install speedtest-cli

Use Case: Check your internet speed first (to rule out local issues).

speedtest-cli

8. headless Chrome (Puppeteer)

Use Case: Simulate real browser interactions.

  1. Install Node.js and Puppeteer:
   npm install puppeteer
  1. Create a script (perf-test.js):
   const puppeteer = require('puppeteer');
   (async () => {
     const browser = await puppeteer.launch();
     const page = await browser.newPage();
     await page.goto('https://example.com');
     const perf = await page.metrics();
     console.log('Performance Metrics:', perf);
     await browser.close();
   })();
  1. Run it:
   node perf-test.js

Key Metrics to Analyze

  • TTFB (Time to First Byte): Server processing time.
  • DNS Lookup: Time to resolve domain to IP.
  • SSL Handshake: Overhead for HTTPS.
  • Content Load Time: Time to download all assets.

Tips for Accurate Testing

  1. Clear DNS cache:
   sudo systemd-resolve --flush-caches  # systemd
  1. Test from multiple locations using tools like curl + proxies.
  2. Run tests multiple times to average results.
  3. Test during peak vs. off-peak hours.

Summary Table

ToolUse CaseKey Feature
curlBasic timing metricsTTFB, DNS, TLS breakdown
abLoad testingConcurrent requests
siegeStress testingSimulate real-world traffic
lighthousePerformance auditSEO, accessibility, best practices
headlessReal browser simulationRender time, JavaScript metrics
Share This Article