tags:

views:

59

answers:

3

Hi,

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

+3  A: 

Just do something like this:

from time import time
starttime = time()
askQuestion()
timetaken = starttime - time()
Mentalikryst
+1  A: 

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)
Ashish
@Ashish: I think by default t.timeit() will run the function 1000000 times instead of only once.To run it only once, you will need to change the code to - *print t.timeit(number=1)*
Ashish
@Ashish: Good point. Made the change.
Ashish
A: 

You might want to look at the timeit module.

import timeit
inspectorG4dget