Created
November 1, 2011 06:02
-
-
Save ivikash/1330030 to your computer and use it in GitHub Desktop.
Testing cProfile
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
import cProfile | |
def fib(n): | |
"""Fibonacci series | |
""" | |
if n==0: | |
return 0 | |
elif n == 1: | |
return 1 | |
else: | |
return fib(n-1) + fib(n-2) | |
def fib_seq(n): | |
""" | |
""" | |
seq = [] | |
if n>0: | |
seq.extend(fib_seq(n-1)) | |
seq.append(fib(n)) | |
return seq | |
print "RAW" | |
print '=' * 80 | |
cProfile.run('print fib_seq(20); print') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment