Python Forum
Timing input - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Timing input (/thread-21987.html)



Timing input - Mark17 - Oct-23-2019

I'm trying to find a simple timing snippet to measure response time.

This repeatedly outputs "it took 0.0 seconds." Why?

import time

y = input("What is 4 * 3?")
start = time.time()
if y=="12":
    end = time.time()
    print("it took", (end-start), "seconds")
else: quit()
I don't understand the time class (object?)... I just found it online. Any explanation would help. Thanks!


RE: Timing input - Yoriz - Oct-23-2019

because the code between the two time calls is done so quickly.


RE: Timing input - Mark17 - Oct-23-2019

(Oct-23-2019, 08:12 PM)Yoriz Wrote: because the code between the two time calls is done so quickly.

I switched around lines 3 and 4.

Thank you!