3

I am starting command line applications from Java. The problem is that starting application from a command line takes much less time than from Java. I heave read various StackOverflow questions similar to mine (for example, this one, other). They complain on the overhead inherent to Java and suggest various approaches to reduce startup overhead. Unfortunately, they do not report back whether they have really reached an improvement.

I have tried several approaches without success. I would like to hear what I am doing wrong. I will not provide slow code for ProcessBuilder.

NuProcess library:

    NuProcessBuilder pb = new NuProcessBuilder(params);
    pb.setCwd(Paths.get(inputFilePath));

    ProcessHandler handler = new ProcessHandler();
    pb.setProcessListener(handler);

    NuProcess process = pb.start();
    process.waitFor(1, TimeUnit.MINUTES); 

Zt-Exec library (uses ProcessBuilder internally):

    String output =
            new ProcessExecutor()
                    .command(params)
                    .readOutput(true)
                    .timeout(1, TimeUnit.MINUTES)
                    .exitValue(0)
                    .directory(new File(inputFilePath))
                    .execute()
                    .outputUTF8();

I did not try this native lib since I saw the question that reported no improvement.

I reach only 2.476 seconds instead of only 869 ms running from command line. This is very critical for my application. These numbers are for Windows 10. I have carried out tests on Linux Ubuntu and got approx. the same ratio.

Any suggestions?

Community
  • 1
  • 1
Antonio
  • 756
  • 7
  • 26
  • Have you found a solution to this problem? I am currently having the same problem in a project and we have tried multiple different things and analyzed the problem in multiple different ways, without success. I have opened a Github Issue on the Docker for Mac Repository, if it still may be of any help to you: https://github.com/docker/for-mac/issues/6401 – Felix Jul 11 '22 at 12:37
  • Hi Felix, I have not found a solution to this problem. – Antonio Jul 15 '22 at 16:55

0 Answers0