python-3.x - AWS vs localhost 上的可变 time.sleep(X.XX) FPS 结果
问题描述
我的异步脚本有一个主循环,在我的本地机器上每秒运行 150 000 次迭代,在 AWS 实例(Windows AMI、Python 3.7)上每秒运行大约 180 000 次迭代。
当我在这个循环中引入 time.sleep(1 / X) 时,我设法在我的本地主机上很好地限制它。例子:
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.
现在的问题是,在 AWS 上,相同的代码,只是在 time.sleep(1 / X) 中更改了“X”。
X = 1 # 我每秒循环 1 个
X = 10 # 我每秒循环 9 次
X = 100 #我每秒循环 64 次
X = 1000 #我每秒循环 64 次
X = 10000 #我每秒循环 64 次
X = 100000 #我每秒循环 64 次
有人可以帮助解释这种行为吗?谢谢你。
解决方案
推荐阅读
- python - 如何在不破坏进度条的情况下在未来打印?
- html - 我的 ng-template 标记不等待 ngIf async 完成
- python - 匹配多个列忽略熊猫中的顺序
- php - PHP\Laravel 中的符号链接问题
- processing - 修复使用 image() 时的空指针异常;进行中
- javascript - 将 fetch() 数据保存到数组变量以在另一个外部函数中使用
- c - 如何在没有 malloc 的情况下使用交换功能?
- ansible - 在 Ansible 中连接 NXOS 模块时出现问题:列表索引超出范围
- linux - Linux 上的 FT_SetEventNotification
- python - 添加作为字符串传递的浮点数