Python 3.x AWS与本地主机上的可变时间睡眠(X.XX)FPS结果
我的异步脚本有一个主循环,在本地机器上每秒运行150000次迭代,在AWS实例(WindowsAMI,Python3.7)上每秒运行大约180000次迭代 当我在这个循环中引入time.sleep(1/X)时,我设法在本地主机上很好地控制它。例如:Python 3.x AWS与本地主机上的可变时间睡眠(X.XX)FPS结果,python-3.x,amazon-web-services,Python 3.x,Amazon Web Services,我的异步脚本有一个主循环,在本地机器上每秒运行150000次迭代,在AWS实例(WindowsAMI,Python3.7)上每秒运行大约180000次迭代 当我在这个循环中引入time.sleep(1/X)时,我设法在本地主机上很好地控制它。例如: while t - tzero < settings.main_loop_seconds: for singleobject in iterable: singleobject.process()
while t - tzero < settings.main_loop_seconds:
for singleobject in iterable:
singleobject.process()
t= time.time()
time.sleep(1/10000)
"""with this I expect a maximum of 10000 iterations per second, and with the time lost to 'process' I get an actual 6500 iterations per second. As expected."""
loopcounter += 1
""" I reset this loopcounter to 0 from another thread (using threading.Timer) It is used for logging the number of loops per second.
而t-tzero
现在的问题是,在AWS上,相同的代码,只是在时间上更改了“X”。sleep(1/X)
X=1#我每秒得到一个循环
X=10#我每秒有9个循环
X=100#我每秒得到64个循环
X=1000#我每秒得到64个循环
X=10000#我每秒得到64个循环
X=100000#我每秒得到64个循环
有人能解释一下这种行为吗?谢谢