I've noticed some strange behaviour that may or may not be specific to my system. (lenovo t430 running windows 8)
With this script:
import time
now = time.time()
while True:
then = now
now = time.time()
dif = now - then
print(dif)
time.sleep(0.01)
I get the following output (what I would consider nominal) with a browser open.
However without a browser open I observe a severe per loop latency.
Obviously this is counter-intuitive as I think anyone would expect better performance when you have fewer concurrant processes.
Any insights or simple replication of these results would be appreciated.
EDIT: Interestingly I observe similar latency with this code:
import time
now = time.time()
def newSleep(mark,duration):
count = 0
while time.time()-mark < duration:
count+=1
print(count)
while True:
then = now
now = time.time()
dif = now - then
print(dif)
#time.sleep(0.01)
newSleep(now,0.01)
While it does provide additional insight - that is some instances of latent loops are due to lack of processor availability (noted by a count of 0 being printed)- I still notice the 15ms behavior where the printed count will be as high as 70k... and 10ms behavior with counts around 40k.