I recently did a small Hello World Time Metric Test to see response time on Node.js and PHP and plotted the graph to see the performance difference between the two. PHP was hosted on a LAMP stack while node.js was downloaded via apt-get install. Instructions can be found on http://nodejs.org .
The node.js script was simple hello world script:
While the PHP script used was:
echo "Hello World";
?>
The tester script was:
Any guesses on which performed better. Node.js was a clear winner over php. Although this script did'nt utilized any event based advantages of node.
In the above chart Column A is Node.js while Column B is PHP.
The node.js script was simple hello world script:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
While the PHP script used was:
echo "Hello World";
?>
The tester script was:
$j=0;
while($j<100) {
$time1=microtime(true);
$i=0;
while($i<10000) {
file_get_contents("http://localhost/hello.php");
$i++;
}
$time2=microtime(true);
print($time2-$time1);
print(' ');
$j++;
}
while($j<100) {
$time1=microtime(true);
$i=0;
while($i<10000) {
file_get_contents("http://localhost/hello.php");
$i++;
}
$time2=microtime(true);
print($time2-$time1);
print(' ');
$j++;
}
Any guesses on which performed better. Node.js was a clear winner over php. Although this script did'nt utilized any event based advantages of node.
In the above chart Column A is Node.js while Column B is PHP.
nice info bro...thanx's & keep write :D
ReplyDeletedont forget visit http://showgan.blogspot.com/