Skip to content

Latest commit

 

History

History
executable file
·
105 lines (85 loc) · 3.44 KB

SPEED-TESTS.md

File metadata and controls

executable file
·
105 lines (85 loc) · 3.44 KB

If you just want the tl;dr on this file, this web server is 10.53% slower than lighttpd running with php-cgi and I didn't test apache

Seriously, it's still incredibly fast. Like 0.05ish seconds vs 0.045ish seconds fast.

To run a speed check, I used these scripts on my computer. This would use the loopback interface, so there would be almost no latency

mkfifo temp
while true; do time curl localhost:4000/color.pyhtml; done &> temp & cat temp | grep real | tee -a full-optimization.log & sleep 30;rm temp; kill $(jobs -p)
while true; do time curl localhost:80/color.php; done &> temp & cat temp | grep real | tee -a lighttpd-php-cgi.log & sleep 30;rm temp; kill $(jobs -p)

There was a dramatic difference, so on a remote host (roughly 60 mb/s down, 80mb/s up), I used these

mkfifi temp
mkfifo temp; while true; do time curl niles.mooo.com:4000/color.pyhtml; done &> temp & cat temp | grep real | tee -a full-optimization-remote.log & sleep 30; kill $(jobs -p)
mkfifo temp; while true; do time curl niles.mooo.com:80/color.php; done &> temp & cat temp | grep real | tee -a lighttpd-php-cgi-remote.log & sleep 30; kill $(jobs -p)

color.pyhtml is in the examples folder

color.php is as follows:

<?php
function newColor() {
	return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}
function fullColor() {
	if (isset($_GET['color'])) {
		return $_GET['color'];
	} else {
		return "#" . newColor() . newColor() . newColor();
	}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Hazel Alder</title>
<link rel="stylesheet" href="/style.css">
</head>
<body style="background-color:<?php echo fullColor() ?>">
<h2>Hazel Alder</h2>
<div id="content">
<h1 style="color:<?php echo fullColor() ?>}">This is running on the mako engine. I'm sure I'll have a use for it sometime</h1>
<form name="input" action="" method="post">
New hex color: <input type="text" name="color"><br>
<input type="submit" value="Submit">
</form>
<hr />
<a href="/ben.pyhtml">Ben is...</a>
</div>
<div id="foot">Niles Rogoff 2013</div>
</body>
</html>

The results are below

$ for x in *.log; do echo -n $x" - ";cat $x|sed -n '$='; done
lighttpd-php-cgi.log - 3438
full-optimization.log - 1437
lighttpd-php-cgi-remote.log - 606
full-optimization-remote.log - 517

And the versions

$ lighttpd -v
lighttpd/1.4.33 (ssl) - a light and fast webserver
Build-Date: Jan 26 2014 11:59:01
$ php-cgi -v
PHP 5.5.8 (cgi-fcgi) (built: Jan 26 2014 12:23:27)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
$ python --version
Python 2.7.6

As you can see, with the loopback interface, lighttpd with php-cgi is far superior.

When actual networking has to be implemented, the difference in render times becomes negligible, a difference of 89 requests over 30 seconds.

I then ran this

$ for x in *.log; do echo -n $x" - "; totalRequests=$(cat $x | sed -n '$='); echo $(($totalRequests/30)); done

to determine the number of requests per second. It returned

full-optimization-remote.log - 17
full-optimization.log - 47
lighttpd-php-cgi-remote.log - 19
lighttpd-php-cgi.log - 114

As you can see, on the local host, there is a very dramatic difference, but from a remote host, it's only 10.53% slower.

Plus, who wants to use PHP anyways.