Watch on YouTube.
When choosing a new server for you website you may need no check performance and choose best option that fits your budget. This simple PHP script can help you to check raw server CPU and disk speed.
bench.php file
<?php
/**
* Simple Server Benchmark Script
* Tests CPU speed and Disk I/O performance.
*/
header('Content-Type: text/plain');
echo "--- Server Benchmark (".$_SERVER['SERVER_ADDR'].") ---\n";
echo "PHP Version: " . PHP_VERSION . "\n";
echo "Server: " . $_SERVER['SERVER_SOFTWARE'] . "\n";
echo "------------------------\n\n";
// --- 1. CPU Benchmark: Mathematical Operations ---
function benchmark_cpu($iterations = 1000000) {
$start = microtime(true);
for ($i = 0; $i < $iterations; $i++) {
$x = sqrt($i) * sin($i) + cos($i);
}
$end = microtime(true);
return round($end - $start, 4);
}
echo "Running CPU Benchmark (Math Loops)...\n";
$cpu_time = benchmark_cpu();
echo "CPU Time: $cpu_time seconds\n\n";
// --- 2. Disk Benchmark: Write & Read ---
function benchmark_disk($file = 'test_bench.tmp', $size_mb = 50) {
$data = str_repeat('0', 1024 * 1024); // 1MB block
// Write Test
$start_w = microtime(true);
$fp = fopen($file, 'w');
for ($i = 0; $i < $size_mb; $i++) {
fwrite($fp, $data);
}
fclose($fp);
$end_w = microtime(true);
$write_time = $end_w - $start_w;
// Read Test
$start_r = microtime(true);
$fp = fopen($file, 'r');
while (!feof($fp)) {
fread($fp, 1024 * 1024);
}
fclose($fp);
$end_r = microtime(true);
$read_time = $end_r - $start_r;
// Cleanup
unlink($file);
return [
'write' => round($size_mb / $write_time, 2),
'read' => round($size_mb / $read_time, 2)
];
}
echo "Running Disk Benchmark (50MB IO)...\n";
$disk_results = benchmark_disk();
echo "Write Speed: " . $disk_results['write'] . " MB/s\n";
echo "Read Speed: " . $disk_results['read'] . " MB/s\n";
echo "\n--- Benchmark Complete ---";
Instructions
Create bench.php file on your server with following code and navigate to it with your web browser. Refresh page couple times to see that results are consistent.
It is helpful to test multiple servers before paying yearly price.
No need to install complete WordPress for checking server performance.
Benchmark can be run on shared servers, VPS, dedicated server or locally on your laptop.
Results
I have been using same dedicated server for more than 10 years. Technology has progressed over that time and for same budget I can get much better server now. This benchmark helped me to choose faster server with more CPU cores and RAM.
Also it helped me to choose between faster VPS and Dedicated server with more RAM. I chose dedicated server even if it is a bit slower than VPS.

Here is the screenshot that compares benchmark of:
- Old dedicated server — Atom n2800, 4GB ram.
- New dedicated server — Xeon 8 core CPU E5-1620 v2, 32 GB ram.
- VPS — Intel 4 virtual cores, 8 GB ram.
- Local server — laptop i3-1315u, 40GB ram.
Why use PHP Benchmark?
- Easy to copy single PHP file before migrating existing files from old server.
- Not all servers disclose CPU (make, model, year, benchmark results etc.)
- Compare relative speed between servers.
- Not all VPS, dedicated server or shared servers have same performance.
- Most popular CMS are built with PHP (WordPress, Opencart etc.)
- Test on daily or monthly purchased servers, pay yearly after making decision.
—
What is next?