from time import time def factorial(n): x = 1 while 1 < n: x *= n n -= 1 return x n = factorial(1000) before = time() for loop in xrange(100): text = str(n) text = str(n) text = str(n) text = str(n) text = str(n) text = str(n) text = str(n) text = str(n) text = str(n) text = str(n) after = time() print "Bench: %.1f ms" % ((after-before) * 1000.0)