我有线程API调用,需要协调API调用时间。你知道吗
应用程序的性质意味着我需要在最大API命中率的基础上运行极薄的边距。你知道吗
目前,我正在使用一个存储上一次API调用时间的共享对象来协调从本地计算机到远程API的API调用时间。你知道吗
为了说明本地计算机和远程API之间的连接速度差异,我使用了一个回退响应测试,如果两个调用过早地命中API,则重新提示API调用,从而导致响应错误。(不过,我真的不喜欢这个解决方案。。。如果你有更好的,请插嘴。)
问题是:
你知道吗时间。时间()并不能在所有平台上提供足够的精度。我需要毫秒精度。你知道吗
你知道吗时钟()据我所知,处理的是过程时间,而不是绝对时间。因此,如果CPU处于不同的负载下,它将根据这些负载差异从绝对时间中分离出来。是这样吗?你知道吗
因此,考虑到这一点,以毫秒精度获得API调用之间的时间差的最佳方法是什么?你知道吗
精度仍然取决于平台,但是您应该使用
timeit.default_timer
。你知道吗从docs:
相关问题 更多 >
编程相关推荐