Created
May 29, 2013 12:39
-
-
Save yvmarques/5669977 to your computer and use it in GitHub Desktop.
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 | |
# Bench functional programming | |
$start = microtime(true); | |
$fact = function($x, $y = 1) use (&$fact) { | |
if ($x == 0) { | |
return $y; | |
} | |
return $fact($x - 1, $y * $x); | |
}; | |
$fact(30000) . "\n"; | |
echo (microtime(true) - $start) * 1000 . "\n"; | |
# Bench traditionnal programming | |
$start = microtime(true); | |
function recurv($x, $y = 1) { | |
if ($x == 0) { | |
return 1; | |
} | |
return recurv($x - 1, $x * $y); | |
} | |
recurv(30000) . "\n"; | |
echo (microtime(true) - $start) * 1000 . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment