Prathap
Prathap

Reputation: 1033

Program execution in Eclipse is very slow when compared to command prompt

I have created a Java program which reads encrypted files from local system and does some processing. Actually I have 20 files to read so I have used threading mechanism to speed up the program execution.

When I run the program in Eclipse it takes more than 30 minutes to complete the execution, whereas if I make a runnable jar and execute the program using command prompt, it takes less than a minute.

Why does running programs in Eclipse take more time than running them in command prompt?

Upvotes: 4

Views: 5877

Answers (5)

Umaimath Thonikkadavan
Umaimath Thonikkadavan

Reputation: 133

Changing jdk 6 to jdk 7 worked perfectly for me. Window->Preferences->Java->Installed JREs

Upvotes: 0

Marko Topolnik
Marko Topolnik

Reputation: 200158

Eclipse's Console view that captures System.out is notoriously slow compared to the regular stdout of the command line. Whenever there is a lot of printing happening in the program, it is to be expected that the program will run significantly slower from Eclipse.

But anyway, unless you are writing a program designed to integrate with other programs via Unix pipes, you should minimize the printing as it will kill performance even at the command line.

Upvotes: 9

logoff
logoff

Reputation: 3446

There are some typical mistakes:

  • Maybe you are executing your program in Debug mode.

    Try to use Run (play symbol inside a green circle) instead of Debug (a green bug)

  • Maybe you are executing your program with a different JVM

    Take a look in Project Properties->Java compiler, Window->Preferences->Java->Compiler and Window->Preferences->Java->Installed JREs

  • The output and input interactions with Java Console of Eclipse JDT differ on performance than standard console.

Upvotes: 1

AlexR
AlexR

Reputation: 115328

I have just did an experiment for you and did not saw so significant difference. I created class that calculates sin() 100000000 times. This program ran ~15 seconds under eclipse and ~14 seconds via command prompt.

So, here are the reasons for slowness in your system I can see at the top of my head:

  1. Be sure that you are not running under debug. Use Run option, not Debug.
  2. Be sure that you do not have some coverage/monitoring developers tools on under eclipse. For example YourKit, Emma etc.
  3. Be sure that your program does not produce significant prints to the console.
  4. Check that you have enough heap memory when running under eclipse

Upvotes: 0

ppeterka
ppeterka

Reputation: 20726

Ensure that you use the Run action in Eclipse, and not Debug, as the latter really has measurable difference, especially if you use conditional breakpoints.

However, I remember having less significant differences arising from the use of the Debug.

Upvotes: 0

Related Questions