This is the mail archive of the java@gcc.gnu.org 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]

Speed Impact experiment on GCJ


Hi, 

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: Client.java IFace.java and Impl.java.

For Client.java

public class Client {
    public static void main(String[] args) throws Exception {
	    BufferedReader tasks =  new BufferedReader(new
FileReader(args[0])),
	    		   sDetails = new BufferedReader(new
FileReader(args[1]));
	    BufferedWriter output = new BufferedWriter(new
FileWriter(args[2]));
	    
	    String line = null;
	    List servers = new LinkedList();
	   
	    while((line = sDetails.readLine()) != null)
	    {
		    Impl obj =  new Impl();
		    servers.add(obj);
	    }
	    
	    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,
1000);
			    if((index +1) < servers.size())
				    index++;
			    else
				    index = 0;
		    }
		    end = System.currentTimeMillis();

		    index = 0;
		    time = end - start;
	
		    output.write(currTask+"\t"+time);
		    output.newLine();
		  }
	    
	    tasks.close();
	    sDetails.close();
	    output.close();
    }
}  

For Impl.java
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++)
		count++;
	return count;
    }
}

For IFace.java
public interface IFace {
    public int ping(int i, int j);
}

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

PREFIX=${HOME}/gcc/bin/
GCJ=${PREFIX}gcj
GRMIC=${PREFIX}grmic
GRMIREGISTRY=${PREFIX}grmiregistry

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

Rui 

 


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