This is the mail archive of the mailing list for the Java project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Speed Impact experiment on GCJ


It looks like you didn't specify optimization in your native compile. This can often make a big difference. You might want to try adding "-O2 -g0" to your compliation flags and try again.

We are big-time users of gcj. On a real-world blend of Java use cases, native-complied GCJ modules are almost always about 30-40% faster than the same code interpreted on Sun (tm) JVM (tm). Sometimes the disparity is even more skewed in native-gcj's favor. If you don't get results like this, something you're doing is wrong.

craig vanderborgh
voxware incorporated

Rui Wang wrote:

I did a simple test to analyse the speed impact of using GCJ between
java bytecode and native machine code. But the result looks not very promising, the data below shows that there
is rather large decrease of speed instead of increase. I couldn't figure out why, any suggestions are appreciated.
The results of my experiment are the followings:

For native version:

Number of calls Execution time (ms)
200.0 1221
300.0 1831
400.0 2446
500.0 3060
For java version:
Number of calls Execution time(ms)
200.0 663
300.0 1007
400.0 1310
500.0 1643
This is how I approached the experiment:
The experiment is done on Linux with Fedora core. I have three java classes: and


public class Client {
   public static void main(String[] args) throws Exception {
        BufferedReader tasks =  new BufferedReader(new
                   sDetails = new BufferedReader(new
        BufferedWriter output = new BufferedWriter(new
                String line = null;
        List servers = new LinkedList();
               while((line = sDetails.readLine()) != null)
            Impl obj =  new Impl();
                double currTask = 0;
        int r = 0, index = 0;
        long start = 0, end = 0, time = 0;
        double throughput = 0, responseTime=0;

        while((line = tasks.readLine()) != null)
            currTask = Double.parseDouble(line);
            start = System.currentTimeMillis();
            for (int i = 0; i < currTask; i++)
                r = ((Impl)servers.get(index)).ping(1000,
                if((index +1) < servers.size())
                    index = 0;
            end = System.currentTimeMillis();

index = 0;
time = end - start;
} For
public class Impl implements IFace {
public Impl(){

   public int ping(int i, int j) {
    int count= 0;
    for(int n = 0 ; n < i*j; n++)
    return count;

public interface IFace {
   public int ping(int i, int j);

I also have a script to compile and run the app.

export PATH=$PATH:/home/pg/n1704655/gcc/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/pg/n1704655/gcc/lib

$GCJ -C -fCLASSPATH=./ *java
sleep 2
echo finish compile

$GCJ --classpath=./ -c Client.class -o Client.o
$GCJ --classpath=./ -c IFace.class -o IFace.o
$GCJ --classpath=./ -c Impl.class -o Impl.o
sleep 2
echo finish creat object files

$GCJ *.o --main=Client -o client

./client task.test servers.d result.d
echo client started

Any ideas why? In the code, I don't think I did anything that will slow
things down.
Thank you very much


Confidentiality Note: This message may contain information which is privileged or confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee responsible for delivering the message to the intended recipient, you are hereby NOTIFIED that any dissemination, distribution, retention, archiving, or copying of this communication is strictly prohibited. If you received this email in error, please notify Voxware immediately by return email to the sender.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]