Skip to content

parhamfa/wpbench

Repository files navigation

WPBench - Hardware-Focused WordPress Benchmarking

WordPress Plugin Version PHP Version License

WPBench is the Geekbench of WordPress β€” a reproducible, hardware-sensitive benchmark designed to help you compare CPU performance across different hosting environments.

Why WPBench?

WordPress requests run single-threaded. CPU performance matters. WPBench helps you:

  • ⚑ Compare hardware objectively across VPS providers
  • πŸ“Š Measure real performance with reproducible benchmarks
  • 🎯 Focus on what matters - single-thread PHP execution, not page size or CSS minification
  • πŸ”§ Test accurately with proper warm-up, percentiles, and environment fingerprinting

Features

  • Quick Test: Reproducible benchmark of core WordPress (bootstrap, queries, templates)
  • URL Test: Real-world testing with your theme, plugins, and content
  • Dual Drivers: WP-CLI (in-process) and HTTP (full-stack) modes
  • Composite Scoring: Single WPBench Score for easy comparison
  • Environment Fingerprinting: CPU, PHP, OPcache, database captured with each run
  • Compare Results: Side-by-side with percentage deltas
  • Export/Import: JSON for sharing across servers
  • Full WP-CLI Support: Automation-ready

Installation

From WordPress Plugin Directory (Coming Soon)

  1. Go to Plugins > Add New
  2. Search for "WPBench"
  3. Click Install and Activate

From Source

git clone https://github.com/parhamfa/wpbench.git
cd wpbench
npm install
npm run build

Then upload to wp-content/plugins/ and activate.

Pre-built Release

Download the latest release and upload via WordPress admin.

Quick Start

Admin UI

  1. Navigate to WPBench in your WordPress admin
  2. Go to Quick Test tab
  3. Click Run Quick Test
  4. View your WPBench Score!

WP-CLI

# Run quick benchmark
wp wpbench quick --iterations=30

# Test specific URLs
wp wpbench urls --url="/" --url="/blog" --iterations=20

# Export results
wp wpbench quick --output=results.json --format=json

# Test from file
echo -e "/\n/blog\n/about" > urls.txt
wp wpbench urls --file=urls.txt --driver=http

Understanding Scores

WPBench Score formula:

Score = 1000 Γ— (baseline_time / your_time)
  • Score = 1000: Matches baseline hardware
  • Score > 1000: Faster than baseline (better CPU)
  • Score < 1000: Slower than baseline

Example: If you score 1500, your hardware is 50% faster than the baseline.

Benchmark Protocol

For accurate, comparable results:

βœ… Keep OPcache enabled βœ… Run when server is idle (no traffic) βœ… Use consistent iterations βœ… Compare same test types βœ… Bypass caching for raw performance

❌ Don't compare HTTP vs WP-CLI ❌ Don't test during traffic ❌ Don't compare different test types

Use Cases

Comparing VPS Providers

  1. Deploy identical site to multiple providers
  2. Run same benchmark on each (e.g., wp wpbench quick --iterations=50)
  3. Compare WPBench Scores
  4. Choose the provider with better CPU performance

Testing PHP Versions

# PHP 7.4
wp wpbench quick --iterations=30 --output=php74.json

# Upgrade to PHP 8.2
# ...

# PHP 8.2
wp wpbench quick --iterations=30 --output=php82.json

# Compare results in admin UI

Hardware Upgrade Validation

  1. Run benchmark: wp wpbench quick --output=before.json
  2. Upgrade CPU/hosting plan
  3. Run benchmark: wp wpbench quick --output=after.json
  4. Import both in admin to see improvement percentage

Architecture

  • Single-threaded sequential execution
  • High-res timing (hrtime/microtime fallback)
  • CPU measurement via getrusage()
  • Percentiles (P50/P95) calculated from samples
  • Warm-up cycles before timed runs
  • Environment guards for load and OPcache checks

API

REST Endpoints

POST /wp-json/wpbench/v1/test/quick
POST /wp-json/wpbench/v1/test/url
GET  /wp-json/wpbench/v1/runs
GET  /wp-json/wpbench/v1/runs/{id}
GET  /wp-json/wpbench/v1/runs/{id}/export
POST /wp-json/wpbench/v1/import
GET  /wp-json/wpbench/v1/settings
POST /wp-json/wpbench/v1/settings

PHP API

use WPBench\Engine\BenchmarkRunner;

$runner = new BenchmarkRunner();

// Quick test
$result = $runner->run_quick_test([
    'iterations' => 30,
    'driver' => 'wpcli',
]);

// URL test
$result = $runner->run_url_test(
    ['/', '/blog'],
    ['iterations' => 20, 'driver' => 'http']
);

Development

Requirements

  • PHP 7.4+
  • WordPress 6.1+
  • Node.js 18+
  • Composer (optional)

Setup

git clone https://github.com/parhamfa/wpbench.git
cd wpbench
npm install
composer install  # optional

Build

# Development
npm start

# Production
npm run build

File Structure

wpbench/
β”œβ”€β”€ wpbench.php              # Main plugin file
β”œβ”€β”€ includes/                # PHP classes
β”‚   β”œβ”€β”€ Data/                # Database layer
β”‚   β”œβ”€β”€ Engine/              # Benchmark engine
β”‚   β”œβ”€β”€ Env/                 # Environment fingerprinting
β”‚   β”œβ”€β”€ Http/                # REST API & middleware
β”‚   └── Cli/                 # WP-CLI commands
β”œβ”€β”€ admin/
β”‚   └── assets/
β”‚       └── src/             # React admin UI
β”œβ”€β”€ composer.json
β”œβ”€β”€ package.json
└── readme.txt              # WordPress.org readme

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

FAQ

Q: Why do I need OPcache? A: Without OPcache, you're measuring PHP parsing, not execution. All production sites use OPcache, so benchmarks should too.

Q: Can I use this to find slow plugins? A: No. WPBench measures hardware, not code quality. Use profiling tools like Query Monitor for debugging.

Q: Should I test with caching enabled? A: For hardware comparison, use bypass cache mode. For "real world" tests, enable caching.

Q: Why can't I compare HTTP and WP-CLI results? A: They measure different things. HTTP includes web server overhead. Keep driver consistent when comparing.

Roadmap

  • v1.1: Major cache plugin detection improvements
  • v1.2: Optional anonymous leaderboard
  • v1.3: Historical trending charts
  • v2.0: Optional concurrent stress profiles

License

GPL-2.0-or-later

Credits

Built with:

Inspired by:

  • Geekbench
  • Industry-standard CPU benchmarking methodologies

Support


Made with ⚑ for the WordPress community

About

Hardware-focused WordPress benchmarking plugin - the Geekbench of WordPress

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published