Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timing input
#1
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!
Reply
#2
because the code between the two time calls is done so quickly.
Reply
#3
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Timing actions with Python dangermaus33 0 1,012 Apr-19-2022, 10:08 PM
Last Post: dangermaus33
  Inconsistent counting / timing with threading rantwhy 1 1,772 Nov-24-2021, 04:04 AM
Last Post: deanhystad
  Synchronization/Timing Problem quest 5 3,004 Mar-31-2021, 10:26 PM
Last Post: quest
  Timing of a while loop stylingpat 4 6,844 Mar-31-2021, 10:48 AM
Last Post: stylingpat
  Assigning Data from one column to another with different associated timing interval alexafshari 1 1,960 Apr-30-2020, 03:59 PM
Last Post: pyzyx3qwerty
  Frequency and timing of psycopg2 commits acecase 0 2,125 Nov-01-2019, 05:50 PM
Last Post: acecase
  Perpetual timing Mark17 3 2,903 Oct-24-2019, 03:46 PM
Last Post: Gribouillis
  Timing functions with multiprocessing mntfr 3 5,014 Nov-18-2018, 06:00 AM
Last Post: woooee
  GPIO output timing help needed skid 5 4,067 Jan-23-2018, 04:12 PM
Last Post: skid
  change timing on py script kwfreverie 2 3,134 Dec-16-2017, 07:35 PM
Last Post: kwfreverie

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020