Question

Hi All,

My application is required to find the time elapsed for downloading a small sized file by using HttpClient (HTTP GET) on Android.

I captured the nanoTime before and after the HttpClient.execute in order to find out the elapsed time. At the same time, I collected the TCP dump to find out the elapsed time between HTTP GET and response 200.

i found that there is the difference of nanoTime is 30% to 50% higher than the elapsed time from TCP dump.

Is there any suggestion to minimize such difference ? Using Httpurlconnection ?

Best regards,

Henry Fok

Was it helpful?

Solution

If it simple GET (without authorization etc) I would go with Socket and implement simply GET method.

https://developer.android.com/reference/java/net/Socket.html

OTHER TIPS

Google recommends using HttpURLConnection. Maybe you can boost speed using SPDY, e.g. with OkHttp, but this must be supported by the web-server.

BTW how did you get TCP dump? On Android device? Rooted? Or on your web-server. If web-server, then your measuring latency, not HttpClient overhead. (Of course you haven't done this, silly question.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top