Python Forum
Time in microseconds seems to update only every millisecond
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Time in microseconds seems to update only every millisecond
#1
Hi all,

I'm trying to time part of a code on microsecond level.
Code below shows the idea.
Result is however that the stored value on changes once every 1000 steps, I Would have expected an continuously increment of the stored value.

Must be something I'm not seeing here, can anyone assist?
from datetime import datetime
import matplotlib.pyplot as plt

log =[]
a=datetime.now().microsecond
for i in range(10000):
    b=datetime.now().microsecond
    log.append(b-a)
    
plt.plot(log)  
Thanks,
Reply
#2
The image I get from your code doesn't look like what I expected from your description
[Image: Figure-1.png]
Reply
#3
I think (do a search to verify for yourself) that a Microsoft OS can only do milliseconds. Linux and Mac will do microseconds.
Reply
#4
Thanks for the replies,

The posted figure is indeed completely different from mine, I get a step function out of it.
https://www.expobrain.net/2013/07/12/tim...platforms/ suggests there is indeed a Windows issue involved here.

Thanks,
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Update Date based on Time/String stevezemlicka 1 2,036 Jan-08-2021, 06:54 PM
Last Post: Gribouillis
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 2,689 Dec-16-2020, 05:26 AM
Last Post: Vokofe
  How to update component props every time when a Dash callback returns? sguzunov 0 2,540 Jul-27-2020, 07:11 AM
Last Post: sguzunov
  Time Difference in Epoch Microseconds then convert to human readable firesh 4 11,643 Feb-27-2018, 09:08 AM
Last Post: firesh

Forum Jump:

User Panel Messages

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