Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Aug 2002 10:55:32 +0800
From:      Huang wen hui <hwh@mail.gddsn.org.cn>
To:        java <java@FreeBSD.ORG>
Subject:   Hotspot vm is extremely slower  than nojit vm on current ?
Message-ID:  <3D59C6A4.5020708@mail.gddsn.org.cn>

next in thread | raw e-mail | index | archive | help
hi,
Mostly hotspot vm is stable and fast, but I got problem with Thread.sleep.
Look at the following simple program, on current hotspot vm is extreamly
slow.

%java -version
java version "1.3.1-p7"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.3.1-p7-root-020727-22:30)
Java HotSpot(TM) Client VM (build 1.3.1-internal, mixed mode)

%~hwh/jre/bin/java -version
java version "1.3.1-p7"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.3.1-p7-root-020727-22:30)
Classic VM (build 1.3.1-p7-root-020727-22:30, green threads, nojit)

%~hwh/jre/bin/java -jar TestTimer.jar ; java -jar TestTimer.jar
query elapse time: 1230
query elapse time: 160177
^^^^^^
%~hwh/jre/bin/java -jar TestTimer.jar ; java -jar TestTimer.jar
query elapse time: 1407
query elapse time: 160256
^^^^^^
%~hwh/jre/bin/java -jar TestTimer.jar ; java -jar TestTimer.jar
query elapse time: 1354
query elapse time: 140221
^^^^^^




---------------------------------------------------------------------------------------------------------
import java.util.*;
import cn.gd.util.Timer;
import cn.gd.util.TimerListener;

import java.sql.*;

public class TestTimer implements cn.gd.util.TimerListener {
Timer timer = new Timer(this,20);

public TestTimer() {
timer.start();
}

public synchronized void TimerEvent(Object object) {

}
public void destoryTimer() {
timer.quit();
}

public void query(){
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();

Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost/seismic?user=test&password=test");
String sql = "select * from station";
Statement st = conn.createStatement();
ResultSet rs = null;

for(int i=0;i<100;i++) {
rs = st.executeQuery(sql);
while(rs.next()) {
String sta = rs.getString("sta");
//System.out.println("sta is: "+sta);
}
rs.close();
}
st.close();
conn.close();
}
catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) throws Exception{
TestTimer tt =new TestTimer();
long now = new java.util.Date().getTime();
//Thread.sleep(60*1000);
tt.query();
System.err.println("query elapse time: "+ (new
java.util.Date().getTime() - now));
tt.destoryTimer();
}
}


public class Timer extends Thread{
private static ThreadGroup tGroup = new ThreadGroup("Timer");
// TimerListener to receive TimerEvent notifications
TimerListener m_timerListener;

// Number of seconds in each timer cycle
int m_cycle;

// Object to be supplied with the TimerEvent notification
Object m_object;
private boolean bQuit = false;

public Timer(TimerListener timerListener, int cycle){
super(tGroup,"TimerThread");
m_timerListener = timerListener;
m_cycle = cycle;
m_object = null;

}

public Timer(TimerListener timerListener, int cycle,
Object object){
super(tGroup,"TimerThread");
m_timerListener = timerListener;
m_cycle = cycle;
m_object = object;
}

public void run(){
this.setName("TimerThread");
// Loop until stopped
while (!bQuit) {
try {

// Sleep for the clock cycle
sleep(m_cycle * 1000);
}
catch (InterruptedException ex) {
}

// Fire a TimerEvent
if (m_timerListener != null) {
m_timerListener.TimerEvent(m_object);
}
}
}

public void quit() {
bQuit = true;
}
}

public interface TimerListener
{

void TimerEvent(Object object);
}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D59C6A4.5020708>