Performance gcj & mysql

ezer andres.a@adinet.com.uy
Mon Sep 8 16:09:00 GMT 2008


I am making a simple test to compare the performance of connection and
execution of an sql query compiling with java sun and gcj

The examples connect, and collect the results on a vector and exit.

import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

public class MysqlConnect{
    public static void main(String[] args) {
	long startTime = System.currentTimeMillis();


	System.out.println("MySQL Connect Example.");
    	Connection conn = null;
	String dbName = "mysql";
    	String driver = "com.mysql.jdbc.Driver";
    	String userName = "root"; 
    	String password = "admin";

	List rows = new ArrayList();
	Statement stmt = null;
	ResultSet rs = null;

    	try {
      		Class.forName(driver).newInstance();
		conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/mysqltest?useJvmCharsetConverters=true&useOldUTF8Behavior=true",
userName, password);
		System.out.println("Connected to the database");

		stmt = conn.createStatement();

		rs = stmt.executeQuery("SELECT id, titulo, descripcion FROM mytable");
		System.out.println("Query executed");			
			while (rs.next()) {
				//System.out.println(rs.getInt("id") + ", " + rs.getString("titulo") +
", " + rs.getString("descripcion"));

				Vector row = new Vector();
	            
				row.add(rs.getInt("id"));
				row.add(rs.getString("titulo"));
				row.add(rs.getString("descripcion"));
	            
				rows.add(row);
			}

		conn.close();
		System.out.println("Disconnected from database");
	} catch (Exception e) {
		e.printStackTrace();
	}

	long stopTime = System.currentTimeMillis();
	long elapsedTime = (stopTime - startTime) / 1000;
	System.out.println("Execution Time: " + elapsedTime + " seconds");
    }
}

Testing with JVM:
-----------------

>java -version
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

>javac -Xlint MysqlConnect.java
>java MysqlConnect

MySQL Connect Example.
Connected to the database
Query executed
Disconnected from database
Execution Time: 3 seconds

Testing with GCJ:
-----------------
>gcj --version
>gcj (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu6)

>gcj --main=MysqlConnect -o mysqlconnect MysqlConnect.java mysql-5.0.8.o
>./mysqlconnect

MySQL Connect Example.
Connected to the database
Query executed
Disconnected from database
Execution Time: 9 seconds

Testing with GCJ-4.3:
-----------------
>gcj-4.3 --version
>gcj-4.3 (Ubuntu 4.3.2-1ubuntu1) 4.3.2

>gcj-4.3 --main=MysqlConnect -o mysqlconnect MysqlConnect.java mysql-5.0.8.o
>./mysqlconnect

MySQL Connect Example.
Connected to the database
Query executed
Disconnected from database
Execution Time: 9 seconds

QUESTIONS:
------------
1) How can i improve performance to do it better than jvm ?
2) ./mysqlconnect stays dependant of the gcj libraries? When i uninstall gcj
the executable complains about libgcj. Is there any way to have it totally
independent, for example i want to copy the executable and mysql-5.0.8.o
library without worring if have have gcj installed on that machine.

-- 
View this message in context: http://www.nabble.com/Performance-gcj---mysql-tp19375453p19375453.html
Sent from the gcc - java mailing list archive at Nabble.com.



More information about the Java mailing list