Java Performance – Achieving Eclipse-Like Speed Without Using Eclipse

javaperformance

I've written a java program that generates all repetitive permutations based on the characters and the length given.

When I execute my code in Eclipse, it generates a file with 1,000,000 permutations in only 15 seconds. Yet if I run the program on the same machine in the command prompt using "java permutation" It takes 1 minute 35 seconds to generate the same 1M permutations..

Why is this? And is there anyway I can get this type of performance without using eclipse?

Edit: Added Java VisualVM results

www.craftboom.co.uk/jvm.png – The CPU usage is higher when running in eclipse. Both CPU and memory usage seem to drop to 0 ocassionally in the shell o_O

EDIT2: Turns out it is a problem printing to the screen. Didn't mention it in my original post, but the program prints each permutation to the console.. Commented that out and saved to a file instead.. now running equally fast in both shell and eclipse. 🙂

Thanks to all for replies.

Best Answer

Longer running times indicate a memory issue. Either you swap to disk or you have many more garbage collections than inside Eclipse (because you have a smaller heap).

Run using a profiler, and see where the time is spent. For Java start with jvisualvm in the JDK.

Related Topic