Skip to content

Instantly share code, notes, and snippets.

@cbiggins
Created September 5, 2011 04:27
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 cbiggins/1194090 to your computer and use it in GitHub Desktop.
Save cbiggins/1194090 to your computer and use it in GitHub Desktop.
Skylines Australia benchmark
<?php
$apache = "184.106.195.185";
$nginx = "184.106.174.162";
$page = '/forums/';
$iterations = 10;
$apache_results = array();
$nginx_results = array();
for ($i = 0; $i < $iterations; $i++) {
print "=======================" . PHP_EOL;
$before = microtime(true);
$tmp = file_get_contents("http://" . $nginx . $page);
$after = microtime(true);
$total = round($after - $before, 2);
$nginx_results[] = $total;
// print "NGINX : " . $total . PHP_EOL;
$before = microtime(true);
$tmp = file_get_contents("http://" . $apache . $page);
$after = microtime(true);
$total = round($after - $before, 2);
$apache_results[] = $total;
// print "APACHE : " . $total . PHP_EOL;
print $i . " iterations so far" . PHP_EOL;
}
print "+++++++++++++++++++++++++" . PHP_EOL;
asort($apache_results);
print "APACHE BEST: " . PHP_EOL;
$count = 0;
foreach($apache_results as $result) {
if ($count <= 5) {
print $result . PHP_EOL;
}
else {
break;
}
$count++;
}
arsort($apache_results);
print "APACHE WORST: " . PHP_EOL;
$count = 0;
foreach($apache_results as $result) {
if ($count <= 5) {
print $result . PHP_EOL;
}
else {
break;
}
$count++;
}
print "APACHE AVERAGE: " . (array_sum($apache_results) / $iterations) . PHP_EOL;
asort($nginx_results);
print "NGINX BEST: " . PHP_EOL;
$count = 0;
foreach($nginx_results as $result) {
if ($count <= 5) {
print $result . PHP_EOL;
}
else {
break;
}
$count++;
}
arsort($nginx_results);
print "NGINX WORST: " . PHP_EOL;
$count = 0;
foreach($nginx_results as $result) {
if ($count <= 5) {
print $result . PHP_EOL;
}
else {
break;
}
$count++;
}
print "NGINX AVERAGE: " . (array_sum($nginx_results) / $iterations) . PHP_EOL;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment