Reputation: 4017
I'm running some experiments and I need to precisely measure participants' response time to questions. I know there are some commercial software, but I was wondering if I can do this with Python. Does python provides suitable functionality to measure the response time in millisecond unit?
Thank you, Joon
Upvotes: 2
Views: 5762
Reputation: 760
Just do something like this:
from time import time
starttime = time()
askQuestion()
timetaken = time() - starttime
Upvotes: 4
Reputation: 7285
You could measure the execution time between the options displayed and the input received.
http://docs.python.org/library/timeit.html
def whatYouWantToMeasure():
pass
if __name__=='__main__':
from timeit import Timer
t = Timer("whatYouWantToMeasure()", "from __main__ import test")
print t.timeit(number=1)
Upvotes: 2
Reputation: 113975
You might want to look at the timeit
module.
import timeit
Upvotes: 1