import time last = time.time() i = 0 def f(): global last, i i += 1 n = time.time() print i, n - last last = n time.sleep(.1*random()) f()
f()