Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java NIO performance on Android

I'm evaluating i-jetty on android. I saw that i-jetty supports NIO and that it enabled by default. This brings me to the point: How does NIO and traditional IO compare on android?

At first glance, it seems that on mobile platform NIO would do better since it may save more memory. On the other hand, the OIO can fit better since usually we don't need many open sockets like we do on Java EE.

like image 355
ApriOri Avatar asked Jul 12 '26 18:07

ApriOri


1 Answers

This is not meant to be an answer. Just want to share the result of a quick manual test with two implementations:

  1. NIO with ION (1.1.5) by Koushik Dutta
  2. OIO with OkHttp (1.1.1) by guys in Square

The test is done on the same device (Android 4.0.4) with LTE. Within 8 mins, 108 requests are made one by one (with no concurrency). The requests break down in 5 parts: NIO -> OIO -> NIO -> OIO -> NIO . The request is a HTTP PUT request to UserGrid API that return the same response that is turned to a String and processed in the same way.

In milliseconds:

NIO/ION 60 times   OIO/OkHttp for 48 times        
 Min.   :  889      Min.   :  629.0
 1st Qu.: 1086      1st Qu.:  774.5
 Median : 1426      Median : 1241.0
 Mean   : 1659      Mean   : 1712.2
 3rd Qu.: 1697      3rd Qu.: 1881.2
 Max.   :10913      Max.   :16333.0

 Std Dev: 1329.406  Std Dev: 2254.099

Remarks:

  • The app is restarted between each part. So the NIO/ION test has one more "first run" that is slightly slower. It shouldn't make a big difference to the average/mean, however.

From this test, you can say NIO is more predictable in response time.

As I said, this is not meant to be answer. I'm interested to see other test result and figure out in which scenario NIO/OIO is better. thx

like image 115
mingfai Avatar answered Jul 14 '26 09:07

mingfai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!