设想情况:
问题1:
什么更便宜?
1.将附加到该位置,直到值不为零或
2.反复获取的位置,直到值不为零为止。
问题2:
返回零的重复fetch是否招致协议开销调用(例如http或ssl )。一个理论例子:假设我从一个不存在(值为零)的位置获取10亿次。谷歌会为这些电话向我收费吗?
另一种理论是:假设10亿部手机要打一次电话,每次通话值为零。谷歌会为此收费吗?
我做的实验:
这段时间我一直依附在这个位置上,但是我决定在重复抓取时获取数据。
我运行的代码(转到伪代码):
func recursiveFetch() {
Log.test("Another call")
firebaseFetch(withKey: "abc123") { (data: [String:Any]) in
if data != nil {
//complete
} else {
recursiveFetch()
}
}
}
结果:
使用普通的wifi,它在得到结果之前递归地执行了9次调用。
Persistance Off normal Wifi
19:58:10.721 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:58:10.842 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:58:10.931 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:58:11.051 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:58:11.118 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:58:11.235 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:58:11.316 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:58:11.427 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:58:11.499 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
使用高延迟的wifi,它接受了2个呼叫。
persistance off high latency
19:59:06.655 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
19:59:06.737 TEST ❇️❇️❇️❇️ in EpisodeCellPresenter.swift:updatePinButtonLabelAfterAction():56:: Another call
关于我处境的钱的问题
是对一个零位置连续进行9个呼叫,最后在第10次尝试中得到一个结果比附加到该位置更多或更便宜吗?
发布于 2018-01-03 20:45:16
你只想听你知道当工作完成后会改变的位置,然后停止倾听。其他的一切都是浪费时间和代码。
https://stackoverflow.com/questions/48088705
复制相似问题