Skip to content

Instantly share code, notes, and snippets.

@laonger
Created November 27, 2013 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laonger/7674875 to your computer and use it in GitHub Desktop.
Save laonger/7674875 to your computer and use it in GitHub Desktop.
python 100000000 loops
>>> def a():
... s = time.time()
... for i in xrange(0, 100000000):
... pass
... print time.time() -s
...
>>> def b():
... s = time.time()
... i = 0
... while i < 100000000:
... i+=1
... print time.time()-s
...
>>> def c():
... s = time.time()
... for i in range(0, 100000000):
... pass
... print time.time()-s
...
>>> a()
3.09057092667
>>> b()
8.92706108093
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment