Over a million developers have joined DZone.

Java can be significantly faster than C

· Java Zone

Learn more about how the Java language, tools and frameworks have been the foundation of countless enterprise systems, brought to you in partnership with Salesforce.

Whether you use Java or C is not always as important as the algorithm you use. Being smarter can make more difference.

You might not see this as a fair test of Java vs C, but in the real world human factors are matter. There is no point saying C is faster in theory but there isn't anyone available to make it so. Its like getting a very cheap price on an item which is not in stock. ;)

Benchmark Shootout

Java is temporarily the fastest for this particular knucleotide benchmark. It is quite likely that if the algorithm I used is translated to C it would be faster again. But for the moment Java is fastest because it uses a different approach in a number of key places.





























Benchmark results at Wed 31st August 2011.

If anyone is interested in translating it to C, I would like to know how much faster it is. ;)

Making it faster again

On my home PC it only takes 0.684 ms, a gain of 2.5x. My PC uses newer hardware (and an over clocked CPU)

The code


From http://vanillajava.blogspot.com/2011/08/java-can-be-significantly-faster-than-c.html

Discover how the Force.com Web Services Connector (WSC) is a code-generation tool and runtime library for use with Force.com Web services, brought to you in partnership with Salesforce.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}