[Ironpython-users] time.sleep slowdown

Andrew Graham andy at agraham.demon.co.uk
Tue Jan 20 13:43:18 CET 2015


You don’t say how long you are trying to sleep for or why you want to sleep, but every time you call Sleep you abandon the rest of your timeslice. If you are trying to sleep for a few milliseconds you may be suprised by how long you actually sleep as your thread has to be rescheduled after the sleep time expires. I haven’t needed to check this on Windows 8 but a few years ago we found that on Windows 7 the minimum sleep time was about 15mS – one system timer tick. In fact I believe this minimum can be shorter if there are no other threads of the same or higher priority are waiting to run but we didn’t notice this happening. Sleep is fine for arbitrary length waits of several hundred milliseconds or more but is useless for accurate timing and doesn’t work properly for short timeouts.

Andy Graham

From: Slide 
Sent: Monday, January 19, 2015 10:27 PM
To: ironpython-users at python.org 
Subject: [Ironpython-users] time.sleep slowdown

We're seeing some weirdness in some embedded scripting. Some of our scripts have calls to time.sleep(), with these calls in place, from run to run of the script, performance drops significantly, but if we remove these calls, we don't see any slowdown. The sleep function is implemented with a call to Thread.Sleep, so I am not sure why this would slow things down so much. Has anyone seen anything like this, and have a way to overcome it? 

Thanks,

slide


--------------------------------------------------------------------------------
_______________________________________________
Ironpython-users mailing list
Ironpython-users at python.org
https://mail.python.org/mailman/listinfo/ironpython-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20150120/4fd37c03/attachment.html>


More information about the Ironpython-users mailing list