Last active
March 15, 2016 15:36
-
-
Save nicolasdanelon/2b964b4fc013889c3277 to your computer and use it in GitHub Desktop.
Node JS vs PHP Fibonacci Sequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Today: | |
Tue Mar 15 12:32:35 ART 2016 | |
PHP Version: | |
PHP 7.0.4 (cli) (built: Mar 5 2016 09:28:27) ( NTS ) | |
Copyright (c) 1997-2016 The PHP Group | |
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies | |
NodeJS Version: | |
v5.8.0 | |
Kernel Version: | |
Linux ultrabook 4.4.5-1-ARCH #1 SMP PREEMPT Thu Mar 10 07:38:19 CET 2016 x86_64 GNU/Linux | |
PHP script result: | |
6765 | |
real 0m0.015s | |
user 0m0.003s | |
sys 0m0.010s | |
NodeJS script result: | |
6765 | |
real 0m0.092s | |
user 0m0.087s | |
sys 0m0.003s | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fibonacci (n) | |
{ | |
if (n == 0) { | |
return 0; | |
} | |
else if (n == 1) | |
{ | |
return 1; | |
} else { | |
return fibonacci( n - 1 ) + fibonacci( n - 2 ); | |
} | |
} | |
console.log( fibonacci(20) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function fibonacci ($n) | |
{ | |
if ($n == 0) { | |
return 0; | |
} | |
else if ($n == 1) | |
{ | |
return 1; | |
} else { | |
return fibonacci( $n - 1 ) + fibonacci( $n - 2 ); | |
} | |
} | |
echo fibonacci(20); | |
echo "\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
clear | |
echo "Today:" | |
date | |
echo "" | |
echo "PHP Version:" | |
php -v | |
echo "" | |
echo "NodeJS Version:" | |
node -v | |
echo "" | |
echo "Kernel Version:" | |
uname -a | |
echo "" | |
echo "PHP script result:" | |
time php fibo.php | |
echo "" | |
echo "NodeJS script result:" | |
time node fibo.js | |
echo "" | |
echo "" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment