I have a program I ported from C to Java. Both apps use quicksort to order some partitioned data (genomic coordinates).
The Java version runs fast, but I'd like to get it closer to the C version. I am using the Sun JDK v6u14.
Obviously I can't get parity with the C application, but I'd like to learn what I can do to eke out as much performance as reasonably possible (within the limits of the environment).
What sorts of things can I do to test performance of different parts of the application, memory usage, etc.? What would I do, specifically?
Also, what tricks can I implement (in general) to change the properties and organization of my classes and variables, reducing memory usage and improving speed?
EDIT : I am using Eclipse and would obviously prefer free options for any third-party tools. Thanks!
If your algorithm is CPU-heavy, you may want to consider taking advantage of parallelisation. You may be able to sort in multiple threads and merge the results back later.
This is however not a decision to be taken lightly, as writing concurrent code is hard.
First caveat - make sure you have done appropriate profiling or benchmarking before embarking on any optimisation work. The results will often enlighten you, and nearly always save you a lot of wasted effort in optimising something that doesn't matter.
Assuming that you do need it, then you can get performance comparable to C in Java, but it takes some effort. You need to know where the JVM is doing "extra work" and avoid these.
In particular:
double
and notDouble
.