su -

yum install openssl-devel

cd /usr/local/src

wget http://nodejs.org/dist/v0.8.15/node-v0.8.15.tar.gz

tar zxvf node-v0.8.15.tar.gz

cd node-v0.8.15

./configure

make

make install

以下是 PHP 與 Node.js 的相同演算法進行效能比較。

Example Source Code:Node.js。

var i, a, b, c, max;
 
max = 1000000000;
 
var d = Date.now();
 
for (i = 0; i < max; i++) {
    a = 1234 + 5678 + i;
    b = 1234 * 5678 + i;
    c = 1234 / 2 + i;
}
 
console.log(Date.now() - d);

Example Source Code:PHP。

$a = null;
$b = null;
$c = null;
$i = null;
$max = 1000000000;
 
$start = microtime(true);
 
for ($i = 0; $i < $max; $i++) {
    $a = 1234 + 5678 + $i;
    $b = 1234 * 5678 + $i;
    $c = 1234 / 2 + $i;
}
 
var_dump(microtime(true) - $start);

Reference:http://serverfault.com/questions/299288/how-do-you-install-node-js-on-centos

Reference:http://net.tutsplus.com/tutorials/javascript-ajax/node-js-for-beginners/

Reference:http://socket.io/

Reference:http://blog.shian.tw/node-js-connection-mysql.html

 

arrow
arrow

    mitblog 發表在 痞客邦 留言(0) 人氣()