Skip to content

Instantly share code, notes, and snippets.

Created October 31, 2013 12:10
Show Gist options
  • Save anonymous/7248647 to your computer and use it in GitHub Desktop.
Save anonymous/7248647 to your computer and use it in GitHub Desktop.
fib bench
#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
*/
(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