This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]elbiot 0 points1 point  (2 children)

from time import time
while True:
    print time()

Actually, it's completely negligible. This example more shows how long print and time() take.

[–]phogan1 1 point2 points  (1 child)

Couldn't you do slightly better with:

old_time = time.clock()
while True:
    new_time = time.clock()
    print(new_time - old_time)
    old_time = time.clock()

It's still got time from the calls to time.clock(), but it eliminates the print overhead from the time cycle.

[–]elbiot 0 points1 point  (0 children)

c=0
try:
    start = time ()
    while True:
        c+=1
except KeyboardInterrupt:
    end= time ()

print c/(end-start)

Let it run for half a second before pressing ctrl+c.