As a psychologist, it's useful to be able to time people's reactions in milliseconds. What kind of accuracy could I expect to get in this regard from Python? From what I've read so far, it doesn't look like I can hope to get precise enough timing to get reliable results, but I'm having difficulty finding good sources. Anyone out there know for sure?
aot 0 Junior Poster in Training
Recommended Answers
Jump to PostIf you have a windows machine, you can achieve accuracy better than 1 millisecond with time.clock() ...
# time.clock() gives wallclock seconds accurate to at least 1 millisecond # it updates every millisecond, but only works with windows # time.time() is more portable, but has quantization errors …
Jump to PostI dont know about python but i assume that like most other languages, there are certain datatypes that offer greater precision?
Jump to PostThe datetime module will do micro-seconds
import datetime print datetime.datetime.now() time_now = datetime.datetime.now() print time_now
Not really! If you look at the output, the digits that correspond to microseconds will always be zeroes. But you could hope for millisecond resolution.
Jump to PostThe hardware should achieve microsecond resolution, but the layers of software you have to go through will negate that!
Even if the Python interpreter has a high priority level, the timing will change, since the operating sytems runs plenty of other programs in the background (keyboard, mouse, screen updates, …
All 14 Replies
jrcagle 77 Practically a Master Poster
aot 0 Junior Poster in Training
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
jbennet 1,618 Most Valuable Poster Team Colleague Featured Poster
aot 0 Junior Poster in Training
woooee 814 Nearly a Posting Maven
jrcagle 77 Practically a Master Poster
Ene Uran 638 Posting Virtuoso
woooee 814 Nearly a Posting Maven
jrcagle 77 Practically a Master Poster
aot 0 Junior Poster in Training
Ene Uran 638 Posting Virtuoso
aot 0 Junior Poster in Training
BBTK 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.