Compared runtime of N-body (gravitational interaction of planets) benchmark implemented in different programming languages (C/C++, C++11, Haskell, Python, Java). All the benchmarks use five million iterations of same algorithm and differ only in terms of the language used to write the program.
The benchmarks were run on Raspberry Pi 4 Model B Rev 1.1, Rev c03111 with 4 GB ram. The single board computer was run in headless mode, without case and heatsink.
The total execution time of each benchmark was recorded with the governor in on-demand, performance, and powersave modes.
Language | Type | On-Demand | Performance | Powersave |
---|---|---|---|---|
C/C++ | Compiled | 1.759s | 1.743s | 4.362s |
C++11 | Compiled | 1.524s | 1.513s | 3.782s |
Haskell | Compiled | 2.658s | 2.649s | 6.663s |
Java | Just-In-Time | 2.885s | 2.453s | 6.063s |
Python | Interpreted | 158.393s | 158.263s | 401.476s |
An additional program was written using python and matplotlib to measure CPU frequency and Temperature while the benchmarks ran. This was also used to check whether the CPU thermal throttled in any benchmark.
The benchmark started at 48s mark and ran for 158.26 seconds.
CPU frequency is fixed at 1.5 GHz. The benchmark started at 17.5s mark and ran for 1.74 seconds.
CPU frequency is dynamic and is adjusted based on utilization.
CPU frequency is fixed at 600 MHz.