Advertisement
pzard

pypy vs cpython

Mar 28th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1.  
  2. #!/usr/bin/python
  3. import time
  4.  
  5. def elapsed_time(functor):
  6.      def decorated(*args, **kwargs):
  7.              start = time.time()
  8.              functor()
  9.              end = time.time()
  10.              print "Elapsed time: %f" % (end-start)
  11.      return decorated
  12.  
  13. @elapsed_time
  14. def sum_function():
  15.     sum = 0
  16.     #for i in xrange(1,1000000+1,1):
  17.     for i in xrange(1,1000000000+1,1):
  18.         sum += i
  19.  
  20.     print sum
  21.  
  22. if __name__ == "__main__":
  23.     sum_function()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement