Friday, September 2, 2011

Java can be significantly faster than C

Preface

When I wrote this article it was to comment on how writing the same algorithm implement a different way can make a major difference. I now believe this is not the point of the web site perhaps shouldn't be the point of this article either. I have written a follow up article.
The importance of innovation

Overview

Whether you use Java or C is not always as important as the approach you use. By "approach" I mean; algorithms not specified in the requirements or "the how" to do something.

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

No comments:

Post a Comment