Longer execution through Java shell than console?

Posted by czuk on Stack Overflow See other posts from Stack Overflow or by czuk
Published on 2010-12-28T11:29:55Z Indexed on 2010/12/28 11:54 UTC
Read the original article Hit count: 232

Filed under:
|
|

I have a script in Python which do some computations. When I run this script in console it takes about 7 minutes to complete but when I run it thought Java shell it takes three times longer. I use following code to execute the script in Java:

this.p = Runtime.getRuntime().exec("script.py --batch", envp);

this.input = new BufferedReader(new InputStreamReader(p.getInputStream()));
this.output = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
this.error = new BufferedReader(new InputStreamReader(p.getErrorStream()));

Do you have any suggestion why the Python script runs three time longer in Java than in a console?

update

The computation goes as follow:

  1. Java sends data to the Python.
  2. Python reads the data.
  3. Python generates a decision tree --- this is a long operation.
  4. Python sends a confirmation that the tree is ready.
  5. Java receives the confirmation.

Later there is a series of communications between Java and Python but it takes only several second.

© Stack Overflow or respective owner

Related posts about java

Related posts about python