I'm looking at JVM performance optimisations at the moment (I'm working on cache-friendly data structures for DBMSs, and interested in how running this stuff on a JVM affects things). As just a little test, I wrote an identical binary search in Java and C over a large array (with randomly increasing contents), with a very large number of iterations. I pregenerated all the search numbers to eliminate discrepancies with regards to time taken for RNG. It turned out that for completely predictable searches C was always a bit faster, and over smaller array sizes C also beat out java. As the array got over about a million elements in size, Java caught up to and then got significantly faster than C.
On further investigation of a 150 million element dataset, Java was performing 1/3 again as many instructions, but missing cache half as much. I've been spending some time looking at all the JVM performance optimisations, but I still haven't worked out why this is - a random binary search isn't exactly a test case that's run time optimisation-specific. It's fascinating stuff, anyway.
On further investigation of a 150 million element dataset, Java was performing 1/3 again as many instructions, but missing cache half as much. I've been spending some time looking at all the JVM performance optimisations, but I still haven't worked out why this is - a random binary search isn't exactly a test case that's run time optimisation-specific. It's fascinating stuff, anyway.