2

I previously used an AsyncTask with javax.net.ssl.HttpsURLConnection to call my REST API but switched to Retrofit as it makes for simpler code and I read everywhere that it is faster.

However, it consistently performs worse. With HttpsURLConnection the GET request itself is around 350 ms, and with the Gson parsing the total is around 420 ms.

With Retrofit, OkHttp3 and Gson, the GET request itself is around 630 ms, and the total 750+ ms.

I'm mainly confused about the GET request, what could cause it to be 80% slower with OkHttp3? Both requests have the same URL and same headers. The performance has been consistent over several days and many rebuilds.

Erik Lumme
  • 5,202
  • 13
  • 27

0 Answers0