python - Real time timer -


i new python gentle.

i have been trying write program counts or measures events in real time. @ moment using sleep command pause event doesn't take account time program takes run. have read on datetime module , can sort of see how used, bit stuck in implementing this.

in short, want program counts 0 100 in real time seconds , milliseconds.

your best bet (besides googling before posting question on so) might this:

  • note time when program starts. start = datetime.datetime.now()
  • do calculations
  • sleep until 100 seconds after start. (start + datetime.timedelta(seconds=100))
    • note won't perfect, since there little overhead involved steps between accessing "current time" , going "sleep" (e.g. subtracting "current time" "wake-up time"). however, if sleep precision needs in seconds, should okay.
  • repeat needed.

if, after trying out, need additional actual implementation of these steps, feel free come , post question on topic.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -