Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Java can be significantly faster than C

DZone's Guide to

Java can be significantly faster than C

· Java Zone
Free Resource

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

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

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
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.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}