Prime Benchmarks Updated

After getting a new MacBook Pro and installing Boot Camp on it so I could boot into Windows or Mac OS X, I’ve rerun some of my prime number mini-benchmarks. I only ran the tests in C++ and latest Java on each OS, skipping C# this time. The charts below summarize the results. Times are in seconds and shorter bars are better. (CSV Data)

Java vs. C++ Prime Finding Benchmarks

The first chart puts the C++ and Java times side by side for each host. The Linked List allocates tons of small objects (one for each prime number found), and the C++ allocator seemed to have significantly improved to be twice as fast as Java and C++ on G5, but otherwise there is not too much difference.

G5 vs Intel Prime Finding Benchmarks

The second chart shows the same data as the first but grouped for comparison of OS/CPU combinations. The Intel CPU (Core 2 Duo @ 2.33 GHz) is noticeably faster than the G5 (2 GHz), but there isn’t a real difference between OSs.

I used latest public versions of Java, which were Java 5 for Mac OS X and Java 6 for Windows XP.

4 thoughts on “Prime Benchmarks Updated”

  1. Some small unrelated tests I did here seem to show that Java 6 has some noticeable speedups. You may want to use the same JVM on both platforms.

  2. Java 6 isn’t generally available on Mac OS X, yet, and I wasn’t up for trying the beta. Given the similarity of the Mac and Windows times, I probably need a better benchmark to see the difference, anyway.

  3. It may be that the benchmarks are of little value for other reasons (being microbenchmarks), but they fairly compare as-is C++ to as-is Java. If the C++ compiler chooses not to implement dynamic optimization in the code it generates but Java does, that’s a difference being compared.

Leave a Reply

Your email address will not be published.