C vs. Java Benchmark Tests
February 23, 2000
Updated: November 10, 2023
Gateway 2000: 200 MHz Pentium MMX with 64 Meg RAM (2000)
Operating System |
Compiler |
Virtual Machine |
Optimized |
Time (seconds) |
Graph of Time |
Linux 2.2.5 |
egcs 2.91.66 |
None |
No |
73 |
|
Yes |
64 |
|
Sun jdk 1.2.2 |
Sun jdk 1.2.2 |
No |
147 |
|
Yes |
146 |
|
IBM jikes 1.06 |
148 |
|
Blackdown jre 1.2.2 RC4 |
86 |
|
kaffe 1.0.5 |
152 |
|
IBM jre 1.1.8 |
81 |
|
Sun jdk 1.2.2 w/ Inprise JIT 1.2.13 |
89 |
|
IBM jre 1.3.0 |
85 |
|
Windows NT 4.0 Service Pack 5 |
Visual C++ 6.0 |
None |
64 |
|
Sun jdk 1.2.2 |
Sun jdk 1.2.2 |
79 |
|
HotSpot 1.0.1 |
79 |
|
Raspberry Pi 4 Model B: Cortex-A72 600-1500 MHz with 4 Gig RAM (2023)
Operating System |
Compiler |
Virtual Machine |
Optimized |
Time (seconds) |
vs Best 2000 Result |
Linux 5.4.0 |
clang 10.0.0 |
llvm 10.0.0 |
No |
0.526 |
122x |
Yes |
0.111 |
576x |
gcc 9.4.0 |
None |
No |
0.568 |
113x |
Yes |
0.117 |
547x |
Temurin jdk 21.0.1 |
Temurin jre 21.0.1 |
|
0.168 |
381x |
MacBook Pro: 2.2 GHz i7 with 16 Gig RAM (2023)
Operating System |
Compiler |
Virtual Machine |
Optimized |
Time (seconds) |
vs Best 2000 Result |
MacOS Ventura 13.6.1 |
clang 15.0.0 |
llvm 15.0.0 |
No |
0.108 |
592x |
Yes |
0.028 |
2286x |
Corretto jdk 11.0.9.1 |
Corretto jre 11.0.9.1 |
|
0.045 |
1422x |
MacBook Pro: M3 with 18 Gig RAM (2024)
Operating System |
Compiler |
Virtual Machine |
Optimized |
Time (seconds) |
vs Best 2000 Result |
MacOS Sonoma 14.5 |
clang 15.0.0 |
llvm 15.0.0 |
No |
0.060 |
1067x |
Yes |
0.015 |
4267x |
Corretto jdk 22.0.1 |
Corretto jre 22.0.1 |
|
0.018 |
3556x |
The C code and Java code are available.
Notes:
- The benchmark test performs 1000 FFTs using the Danielson-Lanczos
method on an array of 2048 double precision complex numbers.
- For the 2023 updates I performed 100,000 FFTs and divided the time
by 100 to arrive at comperable results.
- The array is statically allocated in C, but dynamically allocated
in Java.
- The array indicies were intended to be long integers, but in Java
I had to cast them all to regular ints.
- HotSpot under Windows reported that 0.6% of the time (approx 0.5
seconds) was spend compiling the code.
- The processes were run 3 times and theshortest execution times
reported by the performance monitor is reported here.
- Sun's jdk 1.2.2 for Linux does not include a JIT compiler, so
Linux code is fully interpreted, while Microsoft Java code is compiled
when the interpreter starts.
- Jikes reduced compile time from 2.8 to 0.2 seconds.
- The Blackdown jre includes a JIT compiler. Differences between
the Sun jdk compiler and jikes were negligable.
- The ratio of best Java to C performance under Linux is 1.34. In
order to see
how stable that ratio is I performed 10,000 FFTs using the same
configurations and found a ratio of 1.34. The run time performance for
these numerical tests scales to longer run times.