title: Longer execution through Java shell than console?
body: <p>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:</p>
  
  <pre><code>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()));
  </code></pre>
  
  <p>Do you have any suggestion why the Python script runs three time longer in Java than in a console?</p>
  
  <p><strong>update (29.12.2010)</strong></p>
  
  <p>The computation goes as follow:</p>
  
  <ol>
  <li>Java sends data to the Python.</li>
  <li>Python reads the data.</li>
  <li>Python generates a decision tree --- this is a long operation.</li>
  <li>Python sends a confirmation that the tree is ready.</li>
  <li>Java receives the confirmation.</li>
  </ol>
  
  <p>Later there is a series of communications between Java and Python but it takes only several second.</p>
  
  <p><strong>update (29.12.2010)</strong></p>
  
  <p>Thank you for all your comments and suggestions. It took one working day to find out that my assumption was wrong. The code I used had 'a bug' and in fact different computation were performed in console and in shell. When I fixed it the computation time was the same. </p>
  
  <p><em>Summary</em>: The computation time of a script run in console and in Java shell is almost the same. The additional time for initialize Java VM and IO communication is insignificant. </p>