Created
November 13, 2020 13:44
-
-
Save hmayer/6cc48297d3ce3f19c7f0e1c62a1b86d4 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
❯ cat fibo.php | |
<?php | |
$start = microtime(TRUE); | |
function fib($num) { | |
if ($num <= 1) return 1; | |
return fib($num -1) + fib($num -2); | |
} | |
$num = intval($argv[1]); | |
echo fib($num) . "\n"; | |
$end = microtime(TRUE); | |
$diff = $end - $start; | |
echo "Elapsed: {$diff}s\n"; | |
❯ docker run -it --rm -v $PWD:/app php:5.6-cli-alpine php /app/fibo.php 35 | |
14930352 | |
Elapsed: 7.9945681095123s | |
❯ docker run -it --rm -v $PWD:/app php:7.2-cli-alpine php /app/fibo.php 35 | |
14930352 | |
Elapsed: 1.7204959392548s | |
❯ docker run -it --rm -v $PWD:/app php:7.4-cli-alpine php /app/fibo.php 35 | |
14930352 | |
Elapsed: 1.4975919723511s | |
❯ docker run -it --rm -v $PWD:/app php:8.0.0RC4-cli-alpine php /app/fibo.php 35 | |
14930352 | |
Elapsed: 1.5452818870544s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment