Created
October 31, 2013 12:10
-
-
Save anonymous/7248647 to your computer and use it in GitHub Desktop.
fib bench
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
#include <stdlib.h> | |
int fib(int n) | |
{ | |
if (n < 2) return n; | |
return fib(n - 1) + fib(n - 2); | |
} | |
int main(int argc, char **argv) | |
{ | |
fib(atoi(argv[1])); | |
return 0; | |
} | |
/* | |
% time ./fib 35 | |
./fib 35 0.06s user 0.00s system 97% cpu 0.062 total | |
*/ |
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
(defun fib (n) | |
(declare (optimize (safety 0) (speed 3) (debug 0)) | |
(fixnum n)) | |
(if (< n 2) | |
(the fixnum n) | |
(the fixnum | |
(+ (fib (- n 1)) | |
(fib (- n 2)))))) | |
(time (fib 35)) | |
#| | |
Evaluation took: | |
0.062 seconds of real time | |
0.062400 seconds of total run time (0.062400 user, 0.000000 system) | |
100.00% CPU | |
246,334,591 processor cycles | |
0 bytes consed | |
|# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment