Program execution in Eclipse is very slow compared to the command line

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

When I run the program in Eclipse, it takes more than 30 minutes to complete the execution, whereas if I create an executable jar and run the program using the command line, it takes less than a minute.

Why does running programs in Eclipse take longer than running them on the command line?

+4
source share
5 answers

The view of the Eclipse Console that captures System.out is known to be slow compared to the regular stdout command line. Whenever a lot of printing occurs in a program, you should expect the program to run much slower with Eclipse.

But in any case, if you are not writing a program designed to integrate with other programs through Unix pipes, you should minimize printing, as it will kill performance even on the command line.

+6
source

There are some common mistakes:

  • You may be running your program in debug mode.

    Try using Run (play symbol inside the green circle) instead of Debug (green bug)

  • Perhaps you are running your program using another JVM

    Check out Project Properties->Java compiler , Window->Preferences->Java->Compiler and Window->Preferences->Java->Installed JREs

  • The interaction of output and input with the Java Console Eclipse JDT differs from the performance than the standard console.

+1
source

Make sure you use the Run action in Eclipse and not Debug, since the latter really has a measurable difference, especially if you use conditional breakpoints.

However, I remember that I had less significant differences associated with using Debug.

0
source

I just did an experiment for you and did not see such a significant difference. I created a class that evaluates sin() 100000000 times. This program lasted ~ 15 seconds during an eclipse and ~ 14 seconds through the command line.

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

  • Make sure you are not in debug mode. Use the Run option, not the Debug option.
  • Make sure you donโ€™t have tools to cover / monitor developers on eclipse. For example, YourKit, Emma, โ€‹โ€‹etc.
  • Make sure that your program does not produce significant prints on the console.
  • Make sure you have enough heap memory when working in eclipse mode
0
source

Changing jdk 6 to jdk 7 worked fine for me. Window-> Settings-> Java-> Installed JRE

0
source

Source: https://habr.com/ru/post/1438676/


All Articles