From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24827 invoked by alias); 10 Aug 2008 18:17:50 -0000 Received: (qmail 24819 invoked by uid 22791); 10 Aug 2008 18:17:49 -0000 X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.156) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 10 Aug 2008 18:17:09 +0000 Received: by fg-out-1718.google.com with SMTP id e21so876994fga.28 for ; Sun, 10 Aug 2008 11:17:06 -0700 (PDT) Received: by 10.86.66.11 with SMTP id o11mr6585743fga.25.1218392226161; Sun, 10 Aug 2008 11:17:06 -0700 (PDT) Received: from ?192.168.0.21? ( [88.162.37.242]) by mx.google.com with ESMTPS id d4sm430821fga.8.2008.08.10.11.17.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 10 Aug 2008 11:17:04 -0700 (PDT) Message-ID: <489F309D.3050609@gmail.com> Date: Sun, 10 Aug 2008 18:17:00 -0000 From: Benjamin de Dardel Reply-To: benjamin.de-dardel@laposte.net User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: java@gcc.gnu.org Subject: Performances with gcj Content-Type: multipart/mixed; boundary="------------030207070309090102030903" Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00012.txt.bz2 This is a multi-part message in MIME format. --------------030207070309090102030903 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1189 Hi all, I had to release a program that executes an external process and gets its standard output. I implemented a solution with threads and pipes to redirect inputs and outputs (cf PipeTest.java). I choose the 'find /' command to test it. I'm very surprised about gcj performances which are 5x slowly than sun jvm. In fact, I expected that my compiled program would be faster than all jvm. Do you have an idea about these differences ? Is that the gnu classpath implementation which is quiet slow ? Regards, Benjamin # test1 : bash $ time find / real 2m6.054s user 0m5.260s sys 0m6.990s # test2 : compilation with gcj $ gcj --main=PipeTest -o test.bin PipeTest.java $ time test.bin real 18m50.632s user 4m56.380s sys 8m31.940s real 19m38.148s user 5m9.660s sys 9m44.710s # test3: interpretation with gij $ gcj -C PipeTest.java $ time gij PipeTest real 22m39.882s user 6m7.580s sys 10m26.350s # test4 : interpretation with java $ javac PipeTest.java $ time java PipeTest real 3m35.035s user 1m18.710s sys 0m11.730s ##### compilers ##### $ gcj --version gcj (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu6) $ javac -version javac 1.6.0_03 --------------030207070309090102030903 Content-Type: text/x-java; name="PipeTest.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="PipeTest.java" Content-length: 2658 import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; public class PipeTest { public static void main(String args[]) { System.out.println("START"); try { /* set up pipes */ PipedOutputStream pout1 = new PipedOutputStream(); PipedInputStream pin1 = new PipedInputStream(pout1); PipedOutputStream pout2 = new PipedOutputStream(); PipedInputStream pin2 = new PipedInputStream(pout2); /* construct threads */ Producer prod = new Producer(pout1); Filter filt = new Filter(pin1, pout2); Consumer cons = new Consumer(pin2); /* start threads */ prod.start(); filt.start(); cons.start(); prod.join(); filt.join(); cons.join(); } catch (IOException e) { System.out.println("Error1 : " + e.getMessage()); e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("STOP"); } } class Producer extends Thread { private DataOutputStream out; public Producer(OutputStream os) { out = new DataOutputStream(os); } public void run() { try { Process p1 = Runtime.getRuntime().exec("find /"); try { InputStreamReader isr = new InputStreamReader(p1 .getInputStream()); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { out.writeBytes(line + "\n"); out.flush(); } } catch (IOException ioe) { ioe.printStackTrace(); } out.close(); } catch (Exception e) { System.out.println("Error: " + e); } } } class Filter extends Thread { private BufferedReader in; private DataOutputStream out; public Filter(InputStream is, OutputStream os) { in = new BufferedReader(new InputStreamReader(is)); out = new DataOutputStream(os); } public void run() { String s = ""; while (s != null) { try { s = in.readLine(); // TODO apply filters out.writeBytes(s + "\n"); } catch (IOException e) { System.out.println("Error: " + e); } } try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } class Consumer extends Thread { private BufferedReader in; public Consumer(InputStream is) { in = new BufferedReader(new InputStreamReader(is)); } public void run() { String s = ""; while (s != null) { try { s = in.readLine(); if (s != null) { System.out.println("LINE = " + s); } } catch (IOException e) { System.out.println("Error: " + e); } } } } --------------030207070309090102030903--