«

»

Mar 17

Pi on a Pi for Pi Day

EDIT: The metrics below are skewed. Not all JVM’s are created equal. For updated metrics on the Pi, please see JVM Choice Matters (a lot!).

What better thing to do on Pi Day than to calculate Pi? I figured while I’m at it, I might as well do some performance testing of the Raspberry Pi 2 B. I’m using the following for my comparisons:

Host Description Bits
Pi 2B Quad Core, 900 MHz ARM 7, 1G ram 32
Pi B+ Single core, 700 MHz ARM 6, 512M ram 32
Argentum Quad core AMD A10-5757M at 1400MHz (variable clocking, can be higher), 12G ram 64
Nimbus Eight core AMD FX-8320 running at 3515MHz, 32G ram 64

I’m using a variant of the code at Calculate Pi Inefficiently — I’ve edited it to allow to specify the number of terms on the commandline:

I am using the following script to calculate:

I’m running the script seven (7) times in order to let the host warm up some.

I don’t expect there to be any garbage collections, but just in case ;-). One difference between the original version and the current is the IO — the version I’m running here prints a lot less (and runs much more quickly as a result).

Results (Real time Median in seconds)

Number of Terms Argentum Nimbus Pi 2B Pi B+
1000 0.124 0.075 0.706 1.42
10000 0.131 0.075 0.729 1.426
100000 0.144 0.081 0.664 1.512
1000000 0.143 0.088 0.726 2.195
10000000 0.1995 0.1145 1.5165 9.217
100000000 0.5355000000000001 0.3835 8.2345 79.5255
1000000000 3.8884999999999996 3.062 74.68549999999999 781.9705

Interpreting the results, I observe the following

  • It looks as though the majority of the time for terms up to 1000000 is the JVM initialization. Around 100000000 the 64 bit hosts start to be more efficient — they do not have the huge jump in elapsed time.
  • Garbage Collection is not invoked
  • Since the code is single threaded, the extra cores shouldn’t make much of a difference.
  • The Pi 2B is running Oracle Java 1.8 from the Raspbian distribution; the other three are running OpenJDK 1.7.0_75. I may re-run on Pi B+ using Oracle Java 1.8; I halfway expect an improvement in performance there. Until 10000000, the Pi 2 is running at ~2-3x the performance of the Pi B+. After that it goes to ~9x performance.
  • I think that the HotSpot compiler is kicking in around 100000000 which could explain the radical divergence in runtime.
  • I think that the floating point support for the ARM is not as good as for AMD64 — additionally ARM 6 and ARM 7 have different floating point capabilities.

This was a fun little diversion for Pi Day!

1 ping

  1. JVM Choice Matters (a lot!) » Ramblings

    […] 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 […]

Leave a Reply

%d bloggers like this: