xgrr.de – the whole not the half

things, thoughts and stuff out of life, daily business and computer science

Archive for February 4th, 2010


Comparing Roadsend PHP to PHP/FastCGI

For some projects it might come in handy to have a pre-compiled binary shipped to the customer or run as a separate instance. I took a peek at Roadsend PHP which implemented their own engine and is able to compile PHP source into C binaries which can either run on the command line or with special compilation arguments as a FastCGI program.

But before using it productively and changing a lot of source to make it compatible with the way how Roadsend works I wanted to make sure that the promised performance bonus would be really there. I created a very crude script which does nothing more than to iterate an integer to a certain maximum and measures the time to do this.

NOTE: I know that a proper performance test looks differently and I’m aware that Roadsend PHP can put his design into the works when we deal with a lot of includes. I’ll make another test with including random files to compare if this is impacting the results.

<?php
echo “Simple iteration test to compare performance between interpreted PHP and Roadsend PHP<hr />”;

$max = 1000;
if($_GET["max"] != “” && is_numeric($_GET["max"])) {
$max = $_GET["max"];
}

$start = microtime();

for($i = 0; $i < $max; $i++) {
echo $i.”<br />”;
}

$stop = microtime();
$elapsed = $stop – $start;
echo “<hr />Script took $elapsed seconds to execute”;
?>

To the environment. I didn’t set up a clean room environment. I used my server at home with 2G of memory Athlon64 X2 and a RAID5. Nothing special but I think it resembles real-world situations perfectly (unless you setup a new box for every PHP site you build).

Apache (worker – threaded) is used for serving the requests. FastCGIs are served via mod_fcgid. PHP is also run via mod_fcgid which improved the performance of PHP dramatically so far.

Let’s get to it:

max = 1000
Roadsend PHP: 0.005817
Interpreded PHP: 0.001201

max = 10000
Roadsend PHP: 0.06846
Interpreded PHP: 0.012625

These results are not dramatically but significant. It seems that compiling PHP adds overhead to the execution.