优化排球

时间:2013-07-26 17:11:11

标签: android android-volley

我在android中使用Volley库。我在浏览器中运行相同的url并在不到一秒的时间内返回。我想知道,如何优化Volley? 不清楚Cache Queue Take代表什么,以及为什么它是3.6秒。或为什么缓存队列占用和网络完成被添加为6.8秒的响应时间?如何针对不使用 ETags 的服务优化排球。还有什么是BasicNetwork.logSlowRequests

    07-26 09:52:31.395: D/Volley(5651): [4378] BasicNetwork.logSlowRequests: HTTP response   for request=<[ ]   http://theurl.com/path 0xd6183ced NORMAL 6> [lifetime=3172], [size=940], [rc=200],     [retryCount=0]
    07-26 09:52:31.400: D/Volley(5651): [4377] BasicNetwork.logSlowRequests: HTTP response for request=<[ ]   http://theurl.com/path 0xd6183ced NORMAL 5> [lifetime=3182], [size=940], [rc=200], [retryCount=0]
    07-26 09:52:31.445: D/Volley(5651): [1] MarkerLog.finish: (6848 ms) [ ]   http://theurl.com/path 0xd6183ced NORMAL 6
    07-26 09:52:31.445: D/Volley(5651): [1] MarkerLog.finish: (+0   ) [ 1] add-to-queue
    07-26 09:52:31.445: D/Volley(5651): [1] MarkerLog.finish: (+3622) [4376] cache-queue-take
    07-26 09:52:31.450: D/Volley(5651): [1] MarkerLog.finish: (+6   ) [4376] cache-hit-expired
    07-26 09:52:31.450: D/Volley(5651): [1] MarkerLog.finish: (+0   ) [4378] network-queue-take
    07-26 09:52:31.450: D/Volley(5651): [1] MarkerLog.finish: (+3173) [4378] network-http-complete
    07-26 09:52:31.450: D/Volley(5651): [1] MarkerLog.finish: (+36  ) [4378] network-parse-complete
    07-26 09:52:31.450: D/Volley(5651): [1] MarkerLog.finish: (+11  ) [4378] network-cache-written
    07-26 09:52:31.450: D/Volley(5651): [1] MarkerLog.finish: (+0   ) [4378] post-response
    07-26 09:52:31.455: D/Volley(5651): [1] MarkerLog.finish: (+0   ) [ 1] done
    07-26 09:52:31.455: D/
    07-26 09:52:31.525: D/Volley(5651): [1] MarkerLog.finish: (6998 ms) [ ]   http://myurl  0xd6183ced NORMAL 5
    07-26 09:52:31.525: D/Volley(5651): [1] MarkerLog.finish: (+0   ) [ 1] add-to-queue
    07-26 09:52:31.530: D/Volley(5651): [1] MarkerLog.finish: (+3683) [4376] cache-queue-take
    07-26 09:52:31.530: D/Volley(5651): [1] MarkerLog.finish: (+7   ) [4376] cache-hit-expired
    07-26 09:52:31.530: D/Volley(5651): [1] MarkerLog.finish: (+1   ) [4377] network-queue-take
    07-26 09:52:31.530: D/Volley(5651): [1] MarkerLog.finish: (+3184) [4377] network-http-complete
    07-26 09:52:31.535: D/Volley(5651): [1] MarkerLog.finish: (+39  ) [4377] network-parse-complete
    07-26 09:52:31.535: D/Volley(5651): [1] MarkerLog.finish: (+21  ) [4377] network-cache-written
    07-26 09:52:31.535: D/Volley(5651): [1] MarkerLog.finish: (+0   ) [4377] post-response
    07-26 09:52:31.535: D/Volley(5651): [1] MarkerLog.finish: (+63  ) [ 1] done

3 个答案:

答案 0 :(得分:5)

我刚才在这里回答:How to optimize network-queue-take in android Volley? (Volley Google IO 2013)

logSlowRequests只记录缓慢(超过3000毫秒)的请求,没有什么比这更复杂的了。 network-http-complete是下载请求并将其传递给解析器所需的时间。

答案 1 :(得分:1)

尝试使用此Enhanced-volley

此项目基于Google自己创建的Volley Networking Toolkit for Android。工具包本身非常好且可扩展,但它缺少一些功能。该项目旨在将这些功能添加到Volley工具包中,使其成为更完整的HTTP解决方案。

您也可以自定义使用Java NIO(新IO)的库来改善回调/响应时间。 使用Socket.IO

有些人还尝试使用OKHTTP排球

感谢Mr.Vinay

答案 2 :(得分:0)

我有类似的情况。我没有像您一样注意到时间延迟,但是它显示在浏览器中,而不是我的应用程序中。本质上,清除缓存可以帮助我。

您可以通过以下方式清除缓存:

Requestqueue.getcache().clear();

如果您要为jsonrequest禁用缓存,可以通过以下方式实现:

jsonrequest.setshouldcache(false)

这解决了我的缓存问题。