gpt4 book ai didi

android - Volley : http requests slow

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:39:18 24 4
gpt4 key购买 nike

如果我向同一个 URL 发出两个 HTTP 请求,一个仅使用 HttpClient,另一个使用 Volley,则 Volley 请求需要更长的时间。

例如在我的测试环境中:

  • 直接使用 HttpClient 请求 google.com 平均耗时约 250 毫秒
  • 使用 Volley 请求 google.com 平均耗时约 750 毫秒

这是 Volley 请求示例的日志转储:

11:44:14.766: D/Volley(863): [1] MarkerLog.finish: (773  ms) [ ] http://google.com 0xa46e044c NORMAL 1
11:44:14.766: D/Volley(863): [1] MarkerLog.finish: (+0 ) [ 1] add-to-queue
11:44:14.786: D/Volley(863): [1] MarkerLog.finish: (+0 ) [93] cache-queue-take
11:44:14.786: D/Volley(863): [1] MarkerLog.finish: (+7 ) [93] cache-hit-expired
11:44:14.796: D/Volley(863): [1] MarkerLog.finish: (+1 ) [97] network-queue-take
11:44:14.806: D/Volley(863): [1] MarkerLog.finish: (+722 ) [97] network-http-complete
11:44:14.806: D/Volley(863): [1] MarkerLog.finish: (+20 ) [97] network-parse-complete
11:44:14.816: D/Volley(863): [1] MarkerLog.finish: (+16 ) [97] network-cache-written
11:44:14.826: D/Volley(863): [1] MarkerLog.finish: (+0 ) [97] post-response
11:44:14.836: D/Volley(863): [1] MarkerLog.finish: (+7 ) [ 1] done

如您所见,瓶颈在于实际的 HTTP 请求。为什么这么慢?

最佳答案

看起来 Volley 正在缓存您的响应。直接使用 HttpClient 不会缓存任何内容。

关于android - Volley : http requests slow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16991009/

24 4 0
文章推荐: ios - 如何在 IOS 中的
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com