I wrote the following code in Java to upload a file in Raspberry Pi 3:
String fileUrl = "...";
URL urlObj = new URL(fileUrl);
HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();
InputStream in = con.getInputStream();
byte[] buffer = new byte[8*1024];
long t = System.nanoTime();
int read;
while ((read = in.read(buffer)) != -1) {
System.out.println("Read " + read + "B in " + (System.nanoTime() - t)/1000000.0 + " ms");
t = System.nanoTime();
}
Despite the fact that I use an 8 KB buffer, the average download speed is 1389 V around 205 ms, which corresponds to 6.78 KB / s:
Loading measurement speed
I also noticed that CPU usage when executing this code is always 25%. Since the RPi processor has 4 cores, I believe that it uses 100% of one core. I know this is a weak processor, but downloading a file is not a difficult task, so this strange behavior puzzles me.
source
share