I’m one of the lucky folk who was able to obtain a Raspberry Pi Zero for $5. Originally this was going to be an article reviewing the Pi Zero to see how much of a difference the overclocking really makes. That and my impressions of the Zero will be in a later post.
TL;DR: The choice of JVM makes an enormous difference in how code runs on a machine. Oracle Java outperforms OpenJDK by a considerable margin in the following test.
The test consists of 3 Raspberry Pi computers:
- Pi B+
- Pi 2B
- Pi Zero
I am using a 4.1.18 kernel, as opposed to the 3 series kernel from last March.
I’m using the same code as I did for Pi on a Pi for Pi Day — it’s single threaded and does not need a garbage collection. These two facts remove a lot of differences/advantages between the competitors.
I discovered the disparity first by running the code with OpenJDK 8. It was ridiculously slow. I thought, at first, it might be a difference with changing two variables, so I tried again with OpenJDK 7. The results in this case were much better. Remembering that Oracle’s JDK showed promise, I tried again — that time I had the best results.
All of the times below are user time.
|Number of Terms||OpenJDK 8||OpenJDK 7||Oracle Java 8|
If you notice, the first several sized tests are all around the same time — there is a startup cost which is pretty much constant. Additionally, since the code is single threaded, the additional cores aren’t really making much difference.
So, OpenJDK 8 is approximately 10 times slower than Oracle JDK on the Raspberry Pi. Ouch! OpenJDK 7 isn’t quite so bad, but it’s still over 2 times slower.
I think I know which one I’ll be using…